This page contains guides to set Go related environment variables on various operating systems.
GOPATH can be any directory on your system. In Unix examples, we will set it to $HOME/work. Note that GOPATH must not be the same path as your Go installation. Another common setup is to set GOPATH=$HOME.
Edit your .bash_profile to add the following line:
export GOPATH=$HOME/work
Save and exit your editor. Then, source your ~/.bash_profile.
$ source ~/.bash_profile
Edit ~/.zshrc file to add the following line:
export GOPATH=$HOME/work
Save and exit your editor. Then, source your ~/.zshrc.
$ source ~/.zshrc
Your workspace can be located wherever you like, but we'll use C:\work in this example. Note that GOPATH must not be the same path as your Go installation.
C:\work.GOPATH into the “Variable name” field.C:\work into the “Variable value” field.