英文:
Getting "protoc": executable file not found in $PATH when running "go generate" command
问题
我们有一个用Go语言编写的应用程序,我们正在使用GRPC来定义服务契约。
当我们尝试运行"go generate"命令从proto文件生成存根时,会出现以下错误:
main.go:4: 运行"protoc"时:exec: "protoc": 在$PATH中找不到可执行文件
代码中的命令格式:
//go:generate protoc -I . --go-grpc_out=. --go_out=. ./proto/service.proto
注意:
- 我已经安装了protoc-gen-go和protoc-gen-go-grpc
- 尝试搜索上述错误,但还没有找到解决方案。
英文:
We have an application written in GoLang and we are using GRPC for defining service contracts.
When we try to run "go generate" command to generate stub from proto file it gives following error:
main.go:4: running "protoc": exec: "protoc": executable file not found in $PATH
Command format in code:
//go:generate protoc -I . --go-grpc_out=. --go_out=. ./proto/service.proto
Note:
- I have already installed protoc-gen-go and protoc-gen-go-grpc
- Tried to search for the above error but haven't been able to find a solution yet.
答案1
得分: 3
protoc-gen-go
和protoc-gen-go-grpc
是protoc
的插件。您需要安装protoc
(Protobuf编译器)本身,如Go gRPC - 先决条件中所述。
请访问protobuf - 发布页面进行下载。
在Mac上,您可以使用brew install protobuf
进行安装。
英文:
protoc-gen-go
and protoc-gen-go-grpc
are plugins for protoc
. You need to install the protoc
(the Protobuf compiler) itself, as explained in Go gRPC - Prerequisites.
See protobuf - Releases page for a download.
On a Mac can just use brew install protobuf
.
答案2
得分: 0
为您安装protobuf编译器工具:
yum install protobuf-compiler
英文:
Installing protobuf-complier woker for me.
yum install protobuf-compiler
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论