首页 > 解决方案 > 未知标志:--go_opt 在重新生成 gRPC 代码时

问题描述

我按照此链接https://grpc.io/docs/languages/go/quickstart/中的 gRPC 快速入门文档进行操作,在重新生成 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

标签: gogrpc

解决方案


我有同样的问题。我删除了已安装的 protobuf 编译器,并在 https://grpc.io/docs/protoc-installation/中使用“安装预编译的二进制文件”选项重新安装了 protobuf 编译器。

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"

推荐阅读