protoc-gen-go: program not found or is not executable
There are two ways to install the protobuf compiler, if you're on Ubuntu you can use this,
sudo apt install protobuf-compiler
Then of course there's the standard way,
go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
Here forward it's just adding the path. Assuming when you installed Go you did this,
echo 'export GOPATH=$HOME/Go' >> $HOME/.bashrc
source $HOME/.bashrc
Now you can just extend this,
echo 'export PATH=$PATH:$GOPATH/bin' >> $HOME/.bashrc
source $HOME/.bashrc
Strangely protoc
can't expand ~
.
Resolved by following the steps:
Install go library using: go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
- Run
vim ~/.bash_profile
- Add:
export GO_PATH=~/go
export PATH=$PATH:/$GO_PATH/bin
- Run
source ~/.bash_profile
Reference: Unable to build protobuf to go endpoint
From the github repo this solution has worked for me.
Go version is go version go1.14.1 linux/amd64
Add this to .bashrc
and source it.
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT:$GOPATH:$GOBIN
https://github.com/golang/protobuf/issues/795