gpt4 book ai didi

go - 编译protocol buffer时,缺少输入或程序不可执行错误

转载 作者:行者123 更新时间:2023-12-03 03:14:30 24 4
gpt4 key购买 nike

我正在尝试在 Mac 上制作 golang+grpc 服务器。我安装了 golang、grpc、protocol buffer,并按照此示例检查了 grpc 服务器 https://grpc.io/docs/quickstart/go/问题是当我尝试使用 Protocol Buffer 编译 .proto 文件时,它说“缺少输入”或“程序不可执行”。

安装protocol buffer和grpc

brew install grpc protobuf

安装基于golang的protoc插件

go get github.com/golang/protobuf/protoc-gen-go

协议(protocol)路径

which protoc
/usr/local/bin/protoc

示例位置

/Users/usrname/go/src/google.golang.org/grpc/examples/helloworld

运行原型(prototype)编译器

protoc -I=/Users/username/go/src/google.golang.org/grpc/examples/helloworld/helloworld/ --go_out=/Users/username/go/src/google.golang.org/grpc/examples/helloworld/helloworld/ /Users/username/go/src/google.golang.org/grpc/examples/helloworld/helloworld/helloworld.proto

错误信息

protoc-gen-go: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--go_out: protoc-gen-go: Plugin failed with status code 1.

最佳答案

这在 golang/protobuf issue 795 中提到过

See the Installation section of the page README:

Grab the code from the repository and install the proto package.
The simplest way is to run go get -u github.com/golang/protobuf/protoc-gen-go.

The compiler plugin, protoc-gen-go, will be installed in $GOPATH/bin unless $GOBIN is set. It must be in your $PATH for the protocol compiler, protoc, to find it.

因此,请仔细检查 $GOPATH 的值(如果未设置,则默认为 ~/go)

如果 $GOPATH/bin (或 ~/go/bin)在您的 $PATH 中?

OP camilla确认不是:

$PATH also has :/Users/username/go/bin/protoc-gen-go

它应该有 :/Users/username/go/bin

关于go - 编译protocol buffer时,缺少输入或程序不可执行错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58229740/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com