Go正在打印xgcc版本,而不是安装的Go版本。

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

Go is printing xgcc version but not go installed version

问题

go version命令中,它会打印以下内容:

go version xgcc (Ubuntu 4.9.1-0ubuntu1) 4.9.1 linux/amd64

我的安装版本是最新的,即1.4.2版本,它是从tar版本go1.4.2.linux-amd64.tar.gz安装的。

GO环境变量应该如下所示:

GOARCH="amd64"
GOBIN="/home/user/coding/golang/gocnew/goc/bin"
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/user/coding/golang/gocnew/goc"
GORACE=""
GOROOT="/home/user/go"
GOTOOLDIR="/home/user/go/pkg/tool/linux_amd64"
TERM="dumb"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CXX="g++"
CGO_ENABLED="1"

我希望打印的go版本是1.4.2,那么如何实现呢?

英文:

On go version : It prints

go version xgcc (Ubuntu 4.9.1-0ubuntu1) 4.9.1 linux/amd64

My installed version is the latest one and i.e 1.4.2

which got installed from the tar version : go1.4.2.linux-amd64.tar.gz

GO Environmental variables looks exactly like this:

GOARCH="amd64"
GOBIN="/home/user/coding/golang/gocnew/goc/bin"
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/user/coding/golang/gocnew/goc"
GORACE=""
GOROOT="/home/user/go"
GOTOOLDIR="/home/user/go/pkg/tool/linux_amd64"
TERM="dumb"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CXX="g++"
CGO_ENABLED="1"    

I expect go version to be printed as 1.4.2, so how that can be achieved?

答案1

得分: 18

看起来你安装了两个版本的Go。一个是通过Ubuntu软件包管理器安装的,另一个是你从源代码压缩包中安装的。

为了确认,请尝试移除gccgo:

sudo apt-get remove gccgo

英文:

Looks like you have two versions of Go installed. One from ubuntu package manager and one you installed from source tar.

To confirm kindly try to remove gccgo :

sudo apt-get remove gccgo

答案2

得分: 1

我遇到了同样的问题,并通过以下方式解决:
访问go文件夹:/usr/local/go(go的安装文件夹)
执行以下命令:

添加Go路径

echo 'export GOROOT=/usr/local/go' >> ~/.bashrc

echo 'export GOPATH=$HOME/go' >> ~/.bashrc

echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> ~/.bashrc

然后进入源文件夹并检查go版本:
go version go1.12.2 linux/amd64,它将显示与go文件夹中相同的版本,您可以使用go命令进行工作。

英文:

I got the same issue and i fixed it by this way:
Access to go folder: /usr/local/go (The installation folder of go)
Execute these commands:

Added by Go Path

echo 'export GOROOT=/usr/local/go' >> ~/.bashrc

echo 'export GOPATH=$HOME/go' >> ~/.bashrc

echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> ~/.bashrc

And then go to the source folder and check go version:
go version go1.12.2 linux/amd64 it will be displayed the same version in go folder and you can work with go commands.

huangapple
  • 本文由 发表于 2015年4月8日 20:20:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/29514456.html
匿名

发表评论

匿名网友

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

确定