[英]GOPATH environment variable not getting set in the Fish shell?
I have a ~/.config/fish/config.fish
which contains the following lines:我有一个
~/.config/fish/config.fish
,其中包含以下几行:
set PATH $PATH (go env GOPATH)/bin
set -x GOPATH (go env GOPATH)
If I simply run go env GOPATH
at the command line, I get the default location ( ~/go
):如果我只是在命令行中运行
go env GOPATH
,我会得到默认位置( ~/go
):
> go env GOPATH
/Users/kurt/go
However, the $GOPATH
environment variable is not defined:但是,没有定义
$GOPATH
环境变量:
> echo $GOPATH
Why is the $GOPATH
environment variable not getting set?为什么没有设置
$GOPATH
环境变量?
set -x
will only affect your current session. set -x
只会影响您当前的 session。 Once you logout of that session, the export will go away.一旦您注销 session,导出将 go 消失。
set --export --global
will export your environment across all running fish sessions, however is ephemeral and will not persist after you log out. set --export --global
将在所有正在运行的鱼会话中导出您的环境,但是它是短暂的,并且在您注销后不会持续存在。
set --export --universal
will export your environment across all running fish sessions, and is persistent. set --export --universal
将在所有运行的鱼会话中导出您的环境,并且是持久的。
-g or --global
Causes the specified shell variable to be given a global scope.
Global variables don't disappear and are available to all functions
running in the same shell. They can even be modified.
-U or --universal
Causes the specified shell variable to be given a universal scope.
If this option is supplied, the variable will be shared between all the current
user's fish instances on the current computer, and will be preserved across
restarts of the shell
If you are running a current version of fish, you can use the built in fish_add_path (go env GOPATH)/bin
once and it's done, you don't have to have it in a conf file.如果您正在运行当前版本的 fish,您可以使用内置的
fish_add_path (go env GOPATH)/bin
一次,它就完成了,您不必将它放在 conf 文件中。
To add Go paths to your Fish shell, add the following lines to your config.fish:要将 Go 路径添加到您的 Fish shell,请将以下行添加到您的 config.fish:
set -x GOPATH $HOME/go
set -x PATH $PATH $GOPATH/bin
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.