Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pierre-b
Created March 6, 2017 10:03
Show Gist options
  • Star 44 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save pierre-b/8c3d2d1722f5d88533142a37ade9ecfc to your computer and use it in GitHub Desktop.
Save pierre-b/8c3d2d1722f5d88533142a37ade9ecfc to your computer and use it in GitHub Desktop.
golang fish shell config
# config file
# vim ~/.config/fish/config.fish
# reload the config
# source ~/.config/fish/config.fish
# set the workspace path
set -x GOPATH /users/my-username/go
# add the go bin path to be able to execute our programs
set -x PATH $PATH /usr/local/go/bin $GOPATH/bin
@fishuke
Copy link

fishuke commented Oct 31, 2021

set -x GOPATH $HOME/go
set -x PATH $PATH $GOPATH/bin

This is unrelated. We setup go in usr/local/go not in the main directory.

@christophberger
Copy link

Tip: make use of go env:

set -x GOPATH (go env GOPATH)
set -x PATH $PATH (go env GOPATH)/bin

...or, instead of (go env GOPATH)/bin use (go env GOBIN) if set.

@tigawanna
Copy link

this worked for me given i installed it in the default location /usr/local/go and my go libraries will go into golibs

set -x GOROOT  /usr/local/go
set -x PATH $PATH $GOROOT/bin

set -x GOPATH $HOME/golibs
set -x PATH $PATH $GOPATH/bin

@samocodes
Copy link

this worked for me given i installed it in the default location /usr/local/go and my go libraries will go into golibs

set -x GOROOT  /usr/local/go
set -x PATH $PATH $GOROOT/bin

set -x GOPATH $HOME/golibs
set -x PATH $PATH $GOPATH/bin

I'm getting an error go: go: could not create module cache: mkdir /usr/local/go/pkg/mod: permission denied

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment