Go lang安装问题与./make.bash ubuntu->;窗户

Go lang安装问题与./make.bash ubuntu->;窗户,bash,go,sudo,bootstrapper,Bash,Go,Sudo,Bootstrapper,我试着搜索并找到了很多与我的问题相关的话题,但没有一个我能成功地遵循。 我可以运行和获取,没有问题,但我需要编译到windows中,我遇到了问题,请参见下面的内容 mikhail@mikhail-desktop:/usr/lib/go/src$ sudo ./make.bash # Building C bootstrap tool. cmd/dist go tool dist: $GOROOT is not set correctly or not exported GOROOT=/

我试着搜索并找到了很多与我的问题相关的话题,但没有一个我能成功地遵循。 我可以
运行
获取
,没有问题,但我需要编译到windows中,我遇到了问题,请参见下面的内容

mikhail@mikhail-desktop:/usr/lib/go/src$ sudo ./make.bash 
# Building C bootstrap tool.
cmd/dist
go tool dist: $GOROOT is not set correctly or not exported
    GOROOT=/usr/share/go
    /usr/share/go/include/u.h does not exist
mikhail@mikhail-desktop:/usr/lib/go/src$ go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/mikhail/Documents/FL/0go"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
TERM="dumb"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CXX="g++"
CGO_ENABLED="1"
mikhail@mikhail-desktop:/usr/lib/go/src$ 

出于某种原因,它认为GOROOT是
/usr/share/go
,而实际上它是
/usr/lib/go
,我认为它与Debian/Ubuntu有某种联系。我见过这样的问题,但与0.9有关。版本


我已经将go from source安装到~/go中,然后一切都很顺利,现在我可以在帮助下从ubuntu编译到windows。

sudo
可以清理环境变量,要检查这里是否存在这种情况,请运行
sudo$(which go)env
并检查输出是否符合预期。如果没有,您可以使用
-E
标志保留用户的环境:
sudo-E./make.bash

谢谢!我也有同样的想法,那可能是我需要在/root/.bashrc中设置导出。。。但后来我决定尝试从源代码处安装它,它成功了。。。我现在无法证实你的建议,但我几乎可以肯定你是对的。