First, we need GOPATH
$GOPATH is a folder (or set of folders) specified by its environment variable. We must notice that this is not the
$GOROOT directory where Go is installed.
export GOPATH=$HOME/gocode export PATH=$PATH:$GOPATH/bin
~/gocode path in our computer to store the source of our application and its dependencies. The
GOPATH directory will also store the binaries of their packages.
Then check Go env
You system must have
$GOROOT, below is my Env:
GOARCH="amd64" GOBIN="" GOCHAR="6" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/elpsstu/gocode" GORACE="" GOROOT="/home/pravin/go" GOTOOLDIR="/home/pravin/go/pkg/tool/linux_amd64" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0" CXX="g++" CGO_ENABLED="1"
Now, you run download go package:
go get [-d] [-f] [-fix] [-t] [-u] [build flags] [packages]
Get downloads and installs the packages named by the import paths, along with their dependencies. For more details you can look here.