我通过直接在ubuntu18.04上下载预编译的二进制软件包来安装go1.11.5。现在,我想通过从源代码构建来安装go1.12,因此我遵循Installing Go from source。
我设置了 GOROOT_BOOTSTRAP =〜/ goroot_bootstrap
$ mkdir -p ~/goroot_bootstrap/bin
$ cp /usr/local/go/bin/go ~/goroot_bootstrap/bin/
$ echo "export GOROOT_BOOTSTRAP=~/goroot_bootstrap" >> ~/.bashrc
$ source ~/.bashrc
然后,获取源文件
$ git clone -b release-branch.go1.12 https://github.com/golang/go.git ~/github.com/golang/go
构建
$ cd ~/github.com/golang/go/src
$ ./all.bash
失败,并提示:
Building Go cmd/dist using /home/pi/goroot_bootstrap.
cmd/dist/imports.go:12.2: cannot find package "bufio" in any of:
/home/pi/goroot_bootstrap/src/bufio (from $GOROOT)
/home/pi/go/src/bufio (from $GOPATH)
...
但是如果我设置 GOROOT_BOOTSTRAP = / usr / local / go ,它将成功。
然后,我在src / make.bash中阅读源代码。
166 rm -f cmd/dist/dist
167 GOROOT="$GOROOT_BOOTSTRAP" GOOS="" GOARCH="" GO111MODULE=off "$GOROOT_BOOTSTRAP/bin/go" build -o cmd/dist/dist ./cmd/dist
bootstrap工具链在第167行使用GOROOT =“ $ GOROOT_BOOTSTRAP”构建cmd / dist。
如果我设置了 GOROOT_BOOTSTRAP = / usr / local / go 并且成功,则意味着构建仍依赖于bufio之类的旧软件包。
那么,为什么设置 GOROOT_BOOTSTRAP =〜/ goroot_bootstrap 时失败?
如果设置 GOROOT_BOOTSTRAP = / usr / local / go ,构建是否依赖于旧软件包?
从源代码安装哪种方法是正确的?
任何帮助将不胜感激。