简体   繁体   English

无法使用 protoc-gen-go 构建 protobuf

[英]Unable to build protobuf with protoc-gen-go

I just try to build 100% valid protobuf files on Windows with --go_out protoc plugin but it fails.我只是尝试使用 --go_out protoc 插件在 Windows 上构建 100% 有效的 protobuf 文件,但它失败了。 It doesn't report any error in protobuf files.它不会在 protobuf 文件中报告任何错误。 A only see the generated code as output and the --go_out error message like so: A 只看到生成的代码为 output 和 --go_out 错误消息,如下所示:

<generated code at stdout>
--go_out: protoc-gen-go: Plugin failed with status code 1.

What should I do to fix it?我应该怎么做才能修复它?

Check the encoding and line endings of *.proto files.检查 *.proto 文件的编码和行尾。 In my fileset there were some files in UTF-8 without BOM and windows line endings, and other with Windows-1251 and UNIX line endings.在我的文件集中,UTF-8 中有一些文件没有 BOM 和 windows 行结尾,还有其他带有 Windows-1251 和 UNIX 行结尾的文件。

I fixed it by changing encoding of files to UTF-8 without BOM and windows line endings.我通过将文件的编码更改为没有 BOM 和 windows 行尾的 UTF-8 来修复它。 And protoc built go files successfully.并且 protoc 成功构建了 go 文件。

Did u use the protoc command,你有没有使用 protoc 命令,

You can use following command to build您可以使用以下命令来构建

protoc -I=<ABS_PATH_OUTPUT_DIR> --go_out=<ABS_PATH_PROTO_FILE>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM