Understanding the GOPATH environment variable
The GOPATH environment variable lists places to look for Go code. It defines your workspace. It is likely the only environment variable you’ll need to set when developing Go code.
Official documentation:
How to Write Go Code: The GOPATH environment variable Command go: GOPATH environment variable Normally the GOPATH is set in your shell profile (one of ~/.bashrc, ~/.bash_profile, etc).
When you install packages and build binaries, the Go tool will look for source code in $GOPATH/src/ followed by a package import path in order to resolve dependencies.
[Read More]