其他分享
首页 > 其他分享> > go : 执行protoc -I . helloworld.proto --go_out=plugins=grpc:.时出现问题

go : 执行protoc -I . helloworld.proto --go_out=plugins=grpc:.时出现问题

作者:互联网

E:\Go\go\src\OldPackageTest\grpc_test\proto>protoc -I . helloworld.proto --go_out=plugins=grpc:./
protoc-gen-go: invalid Go import path "." for "helloworld.proto"

The import path must contain at least one forward slash ('/') character.

See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more informat
ion.

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

在proto文件头部将option go_package = ".;proto";改为option go_package = "./;proto";即可解决

syntax = "proto3";
option go_package = "./;proto";

// The greeting service definition.
service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply);
}

// The request message containing the user's name.
message HelloRequest {
  string name = 1;
}

// The response message containing the greetings
message HelloReply {
  string message = 1;
}

标签:protoc,package,proto,go,message,out
来源: https://blog.csdn.net/weixin_44863242/article/details/122677048