英文:
Go lang installation issues with ./make.bash ubuntu->windows
问题
我尝试搜索并找到了很多与我的问题相关的主题,但是我没有成功地按照它们的步骤进行操作。
我可以使用go run
和go get
命令没有问题,但是我需要编译到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
。
英文:
I have tried to search and found a lot of topics which are related to my problem, but none of them I could follow to success.
I can go run
and go get
with no issues, but I need to compile into windows and there I have problems please see bellow
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$
By some reasons it thinks the GOROOT is /usr/share/go
while it actually /usr/lib/go
答案1
得分: 1
sudo
可以清除环境变量,要检查这种情况是否存在,请运行sudo $(which go) env
命令,并检查输出是否符合预期。如果不符合预期,您可以使用-E
标志保留用户的环境变量:sudo -E ./make.bash
。
英文:
sudo
can clean environment variables, to check if that is the case here, run sudo $(which go) env
and check if the output is what you expect. If not, you can keep the enviroment of your user by using the -E
flag: sudo -E ./make.bash
.
答案2
得分: 0
我认为这与Debian/Ubuntu有关。我见过类似的问题,但与0.9版本有关。
我已经从源代码安装了go到~/go目录下,然后一切都很顺利,现在我可以使用使用go进行交叉编译的介绍和LiteIDE在Ubuntu上编译到Windows。
英文:
I think it somehow connected to Debian/Ubuntu thing. I seen such issues but related to 0.9. version.
I have installed go from source into ~/go and then everything went quite OK, now I can compile to windows from ubuntu with help Introduction to cross compilation with go and LiteIDE.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论