Home >Backend Development >Golang >Why Does `protoc-gen-go` Report 'Program Not Found or Not Executable' and How Can I Fix It?

Why Does `protoc-gen-go` Report 'Program Not Found or Not Executable' and How Can I Fix It?

Susan Sarandon
Susan SarandonOriginal
2024-12-03 10:53:08429browse

Why Does `protoc-gen-go` Report

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:

  1. Update your environment variables:
  2. In your ~/.bashrc file, add the following lines:

    export GOPATH=$HOME/go
    export PATH=$PATH:$GOPATH/bin
  3. Install the necessary dependencies:
  4. 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
  1. Generate the Go code:
  2. 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn