V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
thomaswang
V2EX  ›  问与答

proto3

  •  
  •   thomaswang · 2018-11-02 16:39:22 +08:00 · 866 次点击
    这是一个创建于 2001 天前的主题,其中的信息可能已经有所发展或是发生改变。
    syntax = "proto3";
    
    package protobuf;
    
    message Content
    {
       int32     id = 1;
       string    command = 2;
       int32     param_id = 3;
       string    param_string = 4;
    }
    
    message BackContent
    {
       int32     id = 1;
       Auth      auth = 2;
    }
    
    message Auth
    {
        bool    isOk = 1;
        Userinfo useInfo = 2;
    }
    
    message Userinfo
    {
        string nick = 1;
        int32 uid = 2;
        int32 roomId = 3;
        string roomName = 4;
    }
    
    p1 := &protobuf.BackContent{}
    p1.Id = 1
    p1.Auth.IsOk = true // 这一行赋值为什么一直报错, 上面一行就可以的,这个给嵌套的赋值咋操作的
    
    2 条回复    2018-11-02 16:54:00 +08:00
    ffeii
        1
    ffeii  
       2018-11-02 16:47:54 +08:00 via iPhone
    猜测 p1.auth.IsOk = true
    thomaswang
        2
    thomaswang  
    OP
       2018-11-02 16:54:00 +08:00
    ```
    userinfo := &protobuf.Userinfo{}

    auth := &protobuf.Auth{}
    auth.UseInfo = userinfo

    p1.Auth = auth
    ```
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3249 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 13:18 · PVG 21:18 · LAX 06:18 · JFK 09:18
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.