export GOROOT=/usr/local/go
export GOPATH="$HOME/.local/gopath"
export PATH="$GOPATH/bin:$GOROOT/bin:$PATH"

if [[ "$(uname)" = 'Darwin' ]]; then
    export GOROOT=/usr/local/opt/go/libexec
else
    export GOROOT=/usr/local/go
fi
export GOPATH="$HOME/.local/gopath"
export GOBIN="$GOPATH/bin"
export PATH="$GOBIN:$GOROOT/bin:$PATH"

Support Go modules from version 1.14+ on MacOS
fix(go): Support Go modules from version 1.14+ on MacOS

https://golang.org/doc/go1.14#introduction
