Start terminal and type bellow line to edit .bash_profile:
~/.bash_profile; open ~/.bash_profile
if you got the error :
no such file or directory or .bash_profile does not exist
follow the bellow step to create .bash_profile
:
- Type
cd~/
- Type
touch .bash_profile
to create your new file. Type ~/.bash_profile:open ~/.bash_profile
again
Paste bellow code to .bash_profile
then save.
#GOPATH
export GOPATH={Your go path}#GOBIN
export GOBIN=$PATH:$GOPATH/bin#PATH
export PATH=$PATH:$GOBIN
Back to terminal, type bellow line to reload env setting
source ~/.bash_profile
now you can type go env
to check the GOPATH