I am trying to build and install go from source code using this documentation. This works fine when I do like the following:
$ git clone https://go.googlesource.com/go goroot
$ cd goroot
$ git checkout master
$ cd src
$ ./all.bash`
Here I installed go from master branch. But when I checkout to another tag and try to execcute ./all.bash like following:
$ git clone https://go.googlesource.com/go goroot
$ cd goroot
$ git checkout go1.12
$ cd src
$ ./all.bash`
this gives me the folowing error:
go: cannot find main module, but found .git/config in /home/usr/goroot
to create a module there, run:
cd .. && go mod init`
I tried to do as the error message instructed i.e. go mod init , it gives me another error like the followig:
go: cannot determine module path for source directory /home/usr/goroot (outside GOPATH, module path must be specified)
The documentation is out of date.
Installing Go from source for Go 1.4 through Go 1.20 and devel go1.21.
# Go1.4 make.bash uses C - gcc and libc6-dev
$ git clone https://github.com/golang/go -b release-branch.go1.4 --depth 1 ~/go1.4
$ cd ~/go1.4/src && ./make.bash 2>/dev/null
$ git clone https://github.com/golang/go -b release-branch.go1.17 --depth 1 ~/go1.17.13
$ cd ~/go1.17.13/src && ./make.bash
Building Go toolchain1 using /home/rocka2q/go1.4.
Installed Go for linux/amd64 in /home/rocka2q/go1.17.13
Installed commands in /home/rocka2q/go1.17.13/bin
$ git clone https://github.com/golang/go ~/goroot
$ cd ~/goroot/src && git checkout master
Already on 'master'
Your branch is up to date with 'origin/master'.
$ cd ~/goroot/src && ./make.bash
Building Go toolchain1 using /home/rocka2q/go1.17.13.
Installed Go for linux/amd64 in /home/rocka2q/goroot
Installed commands in /home/rocka2q/goroot/bin
$ ~/goroot/bin/go version
go version devel go1.21-0853f8caec Fri Apr 14 20:24:18 2023 +0000 linux/amd64
Checkout another tag.
$ cd ~/goroot/src && git checkout go1.12
HEAD is now at 05e77d4191 [release-branch.go1.12] go1.12
$ cd ~/goroot/src && ./make.bash
Building Go toolchain1 using /home/rocka2q/go1.4.
Installed Go for linux/amd64 in /home/rocka2q/goroot
Installed commands in /home/rocka2q/goroot/bin
$ ~/goroot/bin/go version
go version go1.12 linux/amd64
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With