Home >Backend Development >Golang >Why Does `protoc-gen-go` Report 'Program Not Found or Not Executable' and How Can I Fix It?
protoc-gen-go: Program Not Found or Not Executable
When attempting to generate Go code using protoc, you might encounter the error message: "protoc-gen-go: program not found or is not executable." This issue can arise during the development of Go gRPC applications when trying to generate code from proto files.
Solution for Go 1.17
In Go 1.17 and later versions, installing executables using "go get" is deprecated. To resolve this issue, follow these steps:
In your ~/.bashrc file, add the following lines:
export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin
Install protoc-gen-go using the following command:
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
Install protoc-gen-go-grpc using the following command:
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
Use the following command to generate the Go code from your proto files:
protoc --go-grpc_out=. *.proto
The above is the detailed content of Why Does `protoc-gen-go` Report 'Program Not Found or Not Executable' and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!