Skip to main content

生成proto时报错

报错

D:\go_project\zeroMall\mall\user\rpc>goctl rpc proto -src user.proto -dir .
?[34mprotoc -I=D:\go_project\zeroMall\mall\user\rpc user.proto --go_out=plugins=grpc:D:\go_project\zeroMall\mall\user\rpc\user?[0m
error: protoc-gen-go: unable to determine Go import path for "user.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#package for more information.

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

解决方法:

在.proto文件中一定不要忘了加 option go_package ="“"go/src/microtest/proto"; go/src/microtest/proto这个是项目的绝对路径,不加的话因为找不到路径所以报了上面的错