我遵循了此链接中的 gRPC 快速入门文档 https://grpc.io/docs/languages/go/quickstart/在重新生成 gRPC 代码时,我收到错误(未知标志:--go_opt),如下所示。尝试了所有选项但不起作用。它还给出(未知标志:--go-grpc_opt)错误。
命令 -
$ protoc \
--go_out=Mgrpc/service_config/service_config.proto=/internal/proto/grpc_service_config:. \
--go-grpc_out=Mgrpc/service_config/service_config.proto=/internal/proto/grpc_service_config:. \
--go-grpc_opt=paths=source_relative \
helloworld/helloworld.proto
Error - Unknown flag: --go_opt
最佳答案
我有同样的问题。我删除了已安装的 protobuf 编译器并重新安装了带有“安装预编译二进制文件”选项的 protobuf 编译器
https://grpc.io/docs/protoc-installation/ .
sudo apt-get remove protobuf-compiler
$PB_REL="https://github.com/protocolbuffers/protobuf/releases"
$ curl -LO $PB_REL/download/v3.12.1/protoc-3.12.1-linux-x86_64.zip
$sudo apt install unzip
$unzip protoc-3.12.1-linux-x86_64.zip -d HOME/.local
$export PATH="$PATH:$HOME/.local/bin"
关于go - 未知标志 : --go_opt while regenerating gRPC code,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62909028/