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

StackOverflow https://stackoverflow.com/questions/18478995

  •  26-06-2022
  •  | 
  •  

Pergunta

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

Foi útil?

Solução

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.

Outras dicas

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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top