Multiple GOPATH's in fish shell

时间:2015-08-07 01:59:30

标签: bash go

I'm using fish shell. config.fish has GOPATH environment as:

set -x GOPATH $HOME/Documents/Programming/go/3rdparty:$HOME/Documents/Programming/go/own

I have two problems.

1st: Can't call executables in 3rdparty/bin directly such as golocc or godep. I must go in the directory and call it as ./godep and so on. How can I make godep to be called globally.

2nd: I can't cd to $GOPATH. cd $GOPATH gives

cd: The directory '/Users/xxx/Documents/Programming/go/3rdparty:/Users/xxx/Documents/Programming/go/own' does not exist

I'm guessing both problems occurs because of my GOPATH. What is the problem?

1 个答案:

答案 0 :(得分:2)

GOPATH仅与Go工具包相关,您必须设置PATH变量。

由于你的GOPATH中有多个文件夹,你必须这样做:

set -gx PATH $PATH $HOME/Documents/Programming/go/3rdparty
set -gx PATH $PATH $HOME/Documents/Programming/go/own

对于第二个问题,你根本不能这样做,解决方案就是有多个变量,例如:

set -gx GOPATH1 $HOME/Documents/Programming/go/3rdparty
set -gx GOPATH2 $HOME/Documents/Programming/go/own
set -gx GOPATH $GOPATH1:$GOPATH2
set -gx PATH $PATH $GOPATH1/bin
set -gx PATH $PATH $GOPATH2/bin

然后您就可以cd $GOPATH1$GOPATH2