protoc-gen-go: program not found or is not executable although it's installed

39 views Asked by At

I have installed the go plugins. Still when I try to run events.proto code it shows error:

sudo go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
sudo go install google.golang.org/protobuf/cmd/protoc-gen-go@latest

The file structure:

pegasus@pegasus:~/Documents/eBPF/go-xdp-examples/gRPC_test$ tree
.
└── events.proto

1 directory, 1 file
pegasus@pegasus:~/Documents/eBPF/go-xdp-examples/gRPC_test$ 

The command used to generate go code:

pegasus@pegasus:~/Documents/eBPF/go-xdp-examples/gRPC_test$ sudo protoc --go_out=. --proto_path=/home/pegasus/Documents/eBPF/go-xdp-examples/gRPC_test --go_opt=paths=source_relative   --go-grpc_out=. --go-grpc_opt=paths=source_relative /home/pegasus/Documents/eBPF/go-xdp-examples/gRPC_test/events.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.

Inside my ~/.bashrc

export PATH=$PATH:$(go env GOPATH)/bin

export PATH=$PATH:$HOME/go/bin
export PATH=$PATH:/usr/local/go/bin

Go binary PATH:

pegasus@pegasus:~$ which go
/usr/local/bin/go
pegasus@pegasus:~$ whereis go
go: /usr/bin/go /usr/lib/go /usr/local/bin/go /usr/local/go /usr/share/go /home/pegasus/go/bin/go /usr/share/man/man1/go.1.gz

GOPATH

pegasus@pegasus:~$ go env GOPATH
/home/pegasus/go

go env output:

pegasus@pegasus:~$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/pegasus/.cache/go-build"
GOENV="/home/pegasus/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/pegasus/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/pegasus/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.20"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.20/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build917789205=/tmp/go-build -gno-record-gcc-switches"

How can I fix it? I want to fix the sudo go install issue and the protoc-gen-go issue both. Where should I set my GOBIN? Since I'm new to go maybe I'm asking some naive questions.

0

There are 0 answers