设置GOPATH无效

On MacOS Yosemite, inside my .profile file I have set:

GOPATH="$HOME/go"
PATH="$PATH:$GOPATH/bin"

But go env outputs:

GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH=""
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

I also created .bashrc inside my home folder, added the GOPATH variable to the file, but the end result is the same. And it seems that until I set this path variable, I'm unable to install any Go package. Any ideas what could be wrong?

You need to have export on your declaration, the reason being that when you start an application from shell your app isn't receiving your updated $PATH. When you export a variable it adds it to the list of environmentals sent to all future application invocations.

See here for more information on the environment within a shell.

Also, try investigating the choices between .profile and .bash_profile since if you have a similar export in your .bash_profile and you don't append to the $PATH it will overwrite your export. See this question for more info.

.profile is shell and bash compatible where as .bash_profile is only bash compatible (if you don't know the difference, use .bash_profile).