I have install and setup go.
export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/go/bin
I have created a package at following location.
$HOME/go/src/github.com/shamsher31/gosymbol
I build inside package folder using
go build
It creates binary in bin
folder inside GOPATH
But when I try to run package name from command line it gives following error.
symbol: command not found
How can I execute binary from command line ?
You need following configuration for ubuntu.
$ sudo gedit ~/.bashrc
Add the following config
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go;
export PATH=$PATH:$GOPATH/bin;
/usr/local/go/bin
will be your go installation path and
$GOPATH/bin
will be where your custom build packages will get installed.
I was having a similar problem on OSX, I found this the easiest way to get golang up and running:
With HomeBrew:
brew install go
Then add these to your .bash_profile
:
export PATH=$PATH:$GOPATH/bin
export GOPATH=$HOME/.go
For Go latest version go1.13.7 and above
If you have installed Go in its default location, then you no need to set up the GOROOT
path.
The default location for Unix or macOS is /usr/local/go
and for Windows - c:\Go
.
You can verify the path using the command go env
.
Note: If you are the getting the same error "command not found", then you need to unset GOROOT
.
If you want to set up Go in the preferred location, then you need to export the GOROOT
path like this:
export GOROOT="/your/preferred/location"
and
export PATH="$PATH:$GOROOT/bin"
in .bashrc
or .bash_profile
file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With