go version command shows old version number after update to 1.8

后端 未结 5 1543
清歌不尽
清歌不尽 2021-02-02 09:28

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

相关标签:
5条回答
  • 2021-02-02 09:44

    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.

    0 讨论(0)
  • 2021-02-02 09:47

    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

    0 讨论(0)
  • 2021-02-02 09:48

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

    cp /usr/local/go/bin/* /usr/local/bin/
    
    0 讨论(0)
  • 2021-02-02 09:53

    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
    
    0 讨论(0)
  • 2021-02-02 09:55

    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.

    0 讨论(0)
提交回复
热议问题