I am using go version go1.5.1 linux/amd64
on debian 8.2 3.16.0-4-amd64
. I installed golang
using https://golang.org/doc/install.
This is what i put in my ~/.profile
file
export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/go/bin:/home/shivams/go/bin
Running go env
on my machine is giving this output
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/shivams/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT=""
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
Directory structure inside /home/shivams/go
is {pkg,src,bin}
. Inside src directory it is like test/hello.go
.
If i am in src
dir and run go run test/hello.go
it is running perfectly. Also if i run go build test/hello.go
it will create one executable hello
file in same directory.
But if i try to run go install test/hello.go
then i get this error
go install: no install location for .go files listed on command line (GOBIN not set)
. If i set GOBIN
explicitly then i am not able to see this error.
From what i read my understanding is that if GOPATH is set there is no need to set GOBIN variable.
Am i missing anything here? This is the first time i am trying go and not able to get this working.