修改~/.bash_profile 后 source .bash_profile
go env 可以看到 gopath 是我设置在 bash_profile 的位置,但是关闭 shell 再打开 shell,go env 又变回原来的位置。
~ 下面只有.bash_profle,没有.zshrc
希望大神帮忙解答
1 yangkghjh 2020-05-21 23:17:02 +08:00 /etc/profile 如果你无法确定 bash 配置文件的加载顺序的话 |
2 imBossa OP 这是 /etc/profile 内容 # System-wide .profile for sh(1) if [ -x /usr/libexec/path_helper ]; then eval `/usr/libexec/path_helper -s` fi if [ "${BASH-no}" != "no" ]; then [ -r /etc/bashrc ] && . /etc/bashrc fi |
3 hanjingzhan 2020-05-21 23:25:03 +08:00 via Android brew 直接下? |
4 imBossa OP @hanjingzhan 官网下 dmg 安装的 |
![]() | 5 Vegetable 2020-05-21 23:41:16 +08:00 看起来是因为加载顺序与预期不符造成的,之前的 GOPATH 你没有移除,覆盖了你修改的 GOPATH 。建议你找到之前的变量位置。 ls -la|grep -v ^d|grep "\."|awk '{print $9}'|xargs cat|grep GOPATH 看一下是不是有多处 |
6 charlie21 2020-05-21 23:43:22 +08:00 你的 shell 是 bash 还是 zsh 阿 |
7 youxiachai 2020-05-22 00:49:43 +08:00 mac 10.15 用 zsh.. 没有 zshrc 自己建一个吧。。 |
![]() | 8 aladdindingding 2020-05-22 08:44:22 +08:00 看你的 shell 是 zsh 还是 bash 了 |
9 amare 2020-05-22 09:33:44 +08:00 which go, 应该是被覆盖掉了,删了就好。 |
![]() | 10 hongxi2200 2020-05-22 11:25:28 +08:00 用的是 GoLand 里的 terminal 吗? 听上去像,因为我在 GoLand 的 terminal 里修改过 GOPROXY 在重新打开 terminal 的时候的确也出现了被恢复原样的情况。 可能是 GoLand 的项目设置控制着 go env |
![]() | 11 dafsic 2020-05-22 14:13:38 +08:00 相信我,关机,重启就好了 |
12 imBossa OP @youxiachai 是这个原因,谢谢 |