Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

go version command shows old version number after update to 1.8

Tags:

macos

go

upgrade

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/<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

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.

like image 315
Arnaud H Avatar asked Mar 22 '17 13:03

Arnaud H


People also ask

How do I upgrade to latest version of Golang?

New versions of Go are hosted on the golang.org website here: https://golang.org/dl/. Always download your go version from this official URL. To update your current version, download on this website the targeted version.


2 Answers

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.

like image 136
icza Avatar answered Oct 17 '22 13:10

icza


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
like image 40
Sreenidhi Sreesha Avatar answered Oct 17 '22 12:10

Sreenidhi Sreesha