go version command shows old version number after update to 1.8
Asked Answered
A

6

58

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.

Auroraauroral answered 22/3, 2017 at 13:24 Comment(2)
Execute which go, and you'll see where your old Go resides. Remove it (and references to it).Reel
Oh, I see now! I removed the go folder from usr/local, and the go file in usr/local/bin and it is now showing correctly. Thanks!Auroraauroral
R
40

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.

Reel answered 22/3, 2017 at 13:47 Comment(0)
F
48

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
Figuration answered 12/4, 2018 at 22:16 Comment(4)
+1 - I found that even though I originally installed golang via the .pkg from their website, my /usr/local/bin/go pointed to the brew installation of golang after running brew install dep for another project.Unpeopled
This works best. Brew should know where did you exacly installed go and go binary files.Jolandajolanta
+1 - If which go prints /opt/homebrew/bin/go then you need to upgrade via homebrew, can't use the download from Go's website.God
This is because you installed go with brew. Another way is to uninstalled go from brew and try again. But if it's a dependency of another formulae e.g. golangci-lint just continue updating with brew..Hornwort
R
40

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.

Reel answered 22/3, 2017 at 13:47 Comment(0)
F
18

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

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

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

Farny answered 6/4, 2022 at 10:0 Comment(0)
P
13

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

cp /usr/local/go/bin/* /usr/local/bin/
Pals answered 21/6, 2019 at 8:25 Comment(2)
This did the job for me. 👍Ossuary
Same. I wonder why this isn't something that automatically happens.Etka
S
9

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

Sucrose answered 28/12, 2018 at 16:22 Comment(0)
T
0

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.

Thought answered 8/1, 2021 at 17:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.