Using Go with fish fish shell - error when running `go install /path/to/src`

codysehl picture codysehl · Aug 28, 2013 · Viewed 8.4k times · Source

I am following the "How to Write Code" portion of the golang docs, here. I am also using fish fish shell.

I have followed the tutorial and set the proper environment variables (GOPATH and PATH) but I can't get the command go install github.com/user/hello to work with my installation.
I am getting an error:

can't load package: package github.com/user/hello: import "github.com/user/hello": cannot find package

Answer

codysehl picture codysehl · Aug 28, 2013

I had, in fact, incorrectly set my environment variables. Specifically, when setting GOPATH in my ~/.config/fish/config.fish file I needed to export the variable.

Put these lines in your config.fish for fish shell to use Go:
set -x GOPATH $HOME/path/to/your/workspace

Note the -x. That was what was missing.