Question

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

Was it helpful?

Solution

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.

OTHER TIPS

Even better than editing the config.fish file, run set command with --universal (to persist) and -x (export) in your shell like so:

set --universal -x GOPATH $HOME/path/to/goworkspace
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top