新Sir

导航

 

 

hello.proto

syntax = "proto3";
package helloproto;



message Student {
string name = 1;
bool male = 2;
repeated int32 scores = 3;
}

 

 

命令

protoc --go_out=. hello.proto

 

报错信息

$ protoc --go_out =. hello.proto 
protoc-gen-go: unable to determine Go import path for "hello.proto"

Please specify either:
        • a "go_package" option in the .proto source file, or
        • a "M" argument on the command line.

See https://developers.google.com/protocol-buffers/docs/reference/go-generated#p
ackage for more information.

--go_out: protoc-gen-go: Plugin failed with status code 1.

 

 

hello.proto 添加一下一行

 

option go_package =".";

 

如下:

syntax = "proto3";
package helloproto;

option go_package =".";

message Student {
  string name = 1;
  bool male = 2;
  repeated int32 scores = 3;
}

 

 

在执行命令

protoc --go_out=. hello.proto

 

 

posted on 2022-05-06 15:52  新Sir  阅读(82)  评论(0编辑  收藏  举报