在Mac下使用protoc生成go代码时:
protoc --go_out=. hello.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.
插件安装方式:
$ go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
$ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
解决方案一(推荐):
使用Homebrew安装所需插件:
brew install protoc-gen-go
brew install protoc-gen-go-grpc
检查是否安装成功:
protoc-gen-go --version
解决方案二:
vim ~/.bash_profile
添加:文章来源:https://www.toymoban.com/news/detail-667992.html
export GO_PATH=~/go
export PATH=$PATH:/$GO_PATH/bin
刷新环境变量:文章来源地址https://www.toymoban.com/news/detail-667992.html
source ~/.bash_profile
到了这里,关于Mac下 Error “protoc-gen-go: program not found or is not executable“的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!