Home >Backend Development >Golang >How to Fix the 'protoc-gen-go: program not found or is not executable' Error in gRPC Code Generation?
Generating gRPC Code: Resolving "protoc-gen-go: program not found or is not executable" Error
In attempting to build a gRPC application with Go, users may encounter difficulties when generating code using the "protoc" command. This error message, "protoc-gen-go: program not found or is not executable," indicates that the necessary tools are missing or not configured correctly.
Resolution for Go 1.17
Recent versions of Go have deprecated the use of "go get" for installing executables. Instead, use "go install" as recommended in the official documentation.
Update .bashrc:
export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin
Install Tools:
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
Generate Code:
protoc --go-grpc_out=. *.proto
Additional Notes:
The above is the detailed content of How to Fix the 'protoc-gen-go: program not found or is not executable' Error in gRPC Code Generation?. For more information, please follow other related articles on the PHP Chinese website!