go - 未知标志:--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
解决方案
我有同样的问题。我删除了已安装的 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"
推荐阅读
- python - JMESPath 日期过滤
- google-sheets - 嵌套公式未按预期工作 Google 表格
- html - HTML范围结果到文本文件?
- database - 恢复使用旧版本 mongodump 制作的备份时,最新版本的 mongorestore 非常慢
- json - SCALA 如何将 json 解析回控制器?
- python - 找到元素对的数量,使得它们的总和为 8,数组为 a=[3, 5, 6, 3, 2, 1, 3]
- reactjs - 为什么我的应用程序没有部署在 azure 上
- java - Spring Boot 2 @OrderBy 被忽略
- html - 如何使用 Bootstrap(和 React)使图像居中
- javascript - Javascript 对象存在,但是当我调用一个键时返回未定义