go version命令在更新到1.8版本后显示旧的版本号。

huangapple go评论89阅读模式
英文:

go version command shows old version number after update to 1.8

问题

基本上就是标题所说的。我下载/安装了适用于OS X的Go 1.8,但是当我运行以下命令时:

$ go version
go version go1.7.5 darwin/amd64

我的.bashrc文件如下所示:

# 省略了一些导出

NPM_PACKAGES=/Users/<me>/.npm-packages
NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"

export PATH=~/Library/Python/3.4/bin:$PATH

export GOPATH=$HOME/Go
export PATH=$PATH:/usr/local/go/bin

我的工作空间位于我的主文件夹中名为"Go"的目录中。

到目前为止,我已经检查了以下内容:

  • 我检查了/usr/local/go/bin中的文件,VERSION文件显示为"1.8",所以我知道安装成功了。

  • 我已经重新启动了终端会话,甚至重新启动了电脑,以确保没有其他进程干扰它。

  • 我使用Webstorm作为我的IDE,它正确地识别了1.8作为工作版本。

  • 这不是版本号本身的错误,因为我无法使用在1.8版本中引入的"NextResultSet()" SQL功能。

我认为问题可能是上面的.bashrc文件中的错误配置,因为只有终端卡在旧版本上,但我无法弄清楚问题出在哪里。

英文:

Pretty much the title. I downloaded/installed Go 1.8 for OS X, but when I go

$ go version
go version go1.7.5 darwin/amd64

My .bashrc look like the following

# some exports omitted

NPM_PACKAGES=/Users/&lt;me&gt;/.npm-packages
NODE_PATH=&quot;$NPM_PACKAGES/lib/node_modules:$NODE_PATH&quot;

export PATH=~/Library/Python/3.4/bin:$PATH

export GOPATH=$HOME/Go
export PATH=$PATH:/usr/local/go/bin

My workspace is in a directory called "Go" in my home folder.

What I have checked so far:

  • I've checked the files in /usr/local/go/bin, and the VERSION file states "1.8", so I know the installation was successful.

  • I have also renewed my terminal session, I even rebooted my pc to make sure no other processes were interfering with it.

  • I use Webstorm as my IDE, and it correctly recognized 1.8 as the working version

  • It's not a bug in the version number itself, as I can't use the "NextResultSet()" sql functionality, introduced in version 1.8

I believe the culprit might be a wrong configuration in the .bashrc file above, as only the terminal is stuck on the old version, but I can't figure out what is wrong with it.

答案1

得分: 44

我遇到了同样的问题。即使通过从golang网站下载并在Mac上安装了1.10版本,Mac终端仍然显示1.7版本。

通过Homebrew更新golang可以解决这个问题。

brew update
brew upgrade golang
英文:

I had the same issue. Even after installing golang 1.10 on mac through download from golang website, mac terminal still showed 1.7 version.

Updating golang through homebrew fixed my issue.

brew update
brew upgrade golang

答案2

得分: 39

你显然安装了一个旧版本的Go,否则你就不会看到go version go1.7.5 darwin/amd64作为go version的输出。

IDE可能有更先进的方法来检测Go安装,而不仅仅是扫描PATHGOROOT(这就是为什么你的IDE找到并建议使用更新的Go 1.8)。

执行which go命令,你会看到你的旧Go所在的位置。删除它(以及对它的引用)。

请注意,在你的.bashrc文件中,你将正确的Go bin文件夹追加到PATH的末尾:

export PATH=$PATH:/usr/local/go/bin

这意味着如果PATH包含旧Go安装的bin文件夹(很可能是这样),那么它将用于执行go命令。

英文:

You obviously have an old version of Go installed, else you couldn't see go version go1.7.5 darwin/amd64 as the output of go version.

IDEs might have more advanced method of detecting Go installations other that simply scanning PATH and GOROOT (and that's why your IDE found and suggested the newer Go 1.8).

Execute which go, and you'll see where your old Go resides. Remove it (and references to it).

Note that in your .bashrc you're appending the proper Go bin folder to the end of PATH:

export PATH=$PATH:/usr/local/go/bin

Which means if PATH contains the bin folder of the old Go installation (very likely), that is used to execute the go command.

答案3

得分: 14

我手动删除了旧的Go版本,方法是进入/usr/local/bin文件夹。

  1. 首先检查旧的Go版本的路径:
    which go
  2. 打开包含Go文件的文件夹:
    open /usr/local/bin
  3. 删除Go文件。

现在检查版本,应该显示更新的版本。

英文:

I manually deleted the old go version by going to the /usr/local/bin folder.

  1. First check the path for old go version: <br>
    which go
  2. Open the folder containing the go file: <br>
    open /usr/local/bin
  3. Delete the go file.

Check the version now, it'll show the updated version.

答案4

得分: 12

在我的情况下,重新安装后我不得不手动替换二进制文件。

cp /usr/local/go/bin/* /usr/local/bin/
英文:

In my case, I had to replace binary files manually after re-installation.

cp /usr/local/go/bin/* /usr/local/bin/

答案5

得分: 9

TLDR
我通过将链接从安装文件夹移动到/usr/bin/go解决了我的问题。


逐步操作:

  1. 查找go二进制文件:

     $which go
     /usr/bin/go
    
  2. 创建符号链接:

     ln -s /usr/local/go/bin/go go
     ln -s /usr/local/go/bin/godoc godoc
     ln -s /usr/local/go/bin/gofmt gofmt
    
  3. 将这三个符号链接复制到/usr/bin目录下。

英文:

TLDR
I've resolved my problem by moving link to go binary from installation folder to /usr/bin/go


Step by step:

  1. find go binary:

     $which go
     /usr/bin/go
    
  2. create symlinks:

     ln -s /usr/local/go/bin/go go
     ln -s /usr/local/go/bin/godoc godoc
     ln -s /usr/local/go/bin/gofmt gofmt
    
  3. copy those 3 symlinks to /usr/bin

答案6

得分: 0

我从https://golang.org/doc/install安装了最新版本。这将替换默认路径中的版本,对于Mac来说,默认路径是/usr/local/go/bin/go,并且不需要对~/.bashrc/ ~/.bash_profile进行任何手动更改,除非默认路径从未设置过。

英文:

I installed the latest version from https://golang.org/doc/install
That will replace the one in the default path which is /usr/local/go/bin/go for mac and doesn't require any manual changes to ~/.bashrc/ ~/.bash_profile on mac unless the default path was never set.

huangapple
  • 本文由 发表于 2017年3月22日 21:24:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/42952979.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定