英文:
WARNING: Missing 'go_package' option
问题
当我运行协议命令生成pb.go文件时,我遇到了以下错误。但是我可以生成pb.go文件。我该如何解决以下错误?
在"job.proto"中缺少"go_package"选项,
请使用完整的Go包路径指定它,
因为protoc-gen-go的未来版本将要求指定此选项。
英文:
Im getting the following error once i run the protocol command to generate pb.go file
But I can generate the pb.go file. how do I mitigate the following error
Missing 'go_package' option in "job.proto",
please specify it with the full Go package path as
a future release of protoc-gen-go will require this be specified.
答案1
得分: 4
"Import path"是另一个包用来导入生成的代码的路径,例如github.com/me/myproject/model,或者您可以根据您的偏好简单地定义导入路径。
您可以按照以下方式简单地定义您的可选导入路径:
option go_package = ".;<您的导入路径>";
例如,我们可以将包路径假设为"/pub",那么语句如下所示:
option go_package = ".;pub";
然后,您可以简单地执行protoc命令来生成pb.go文件:
protoc -I=<绝对路径输出目录> --go_out=<绝对路径proto文件>
英文:
"Import path" is the path another package would use to import the generated code, e.g. github.com/me/myproject/model or You can simply define the import path based on your preference.
You can simply define your optional import path as follows
option go_package = ".;<Your_Import_path>";
For example, we can assume the package path as "/pub", So the statement as follows.
option go_package = ".;pub";
Then you can simply execute the protoc command to generate the pb.go file
protoc -I=<ABS_PATH_OUTPUT_DIR> --go_out=<ABS_PATH_PROTO_FILE>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论