duanliaozhi2915 2015-07-10 01:29
浏览 23
已采纳

golang在嵌套结构中初始化内部结构对象

I have a nested struct

type Posts struct {
    Id        int
    CreatedAt time.Time
    Data      struct {
        Title    string
        UserName string
    }
}

I want to create a Data object but var innerData Posts.Data doesn't seem to work. I don't want to create separate Data struct because I'm planning to avoid name collusions by having multiple structs which will have different inner structs named Data.

  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 用MATLAB解决问题,需要代码
      • ¥45 关于C语言设计井字棋游戏问题的实现
      • ¥15 python定义一个学生类
      • ¥20 vuforia的Unity3D开发,模型附上特效后大量报错
      • ¥35 Python实现文本关键词提取
      • ¥20 如何使用c++语言完成实验仪器管理系统
      • ¥15 请问Unity使用Magica Cloth插件怎么调整散兵的帘子和振袖比较好?
      • ¥15 请问为什么原神模型导入Unity做动画默认姿势会站不直?
      • ¥15 ld: cannot open C:\Program: No such file or directory
      • ¥15 请问汏佬要怎么访问这种过滤了post和get的php内容?