This is part of a larger group activity,
[gophersource], where you can join in and learn how to contribute to upstream Go and other OSS projects.
- Find the docs to build go from source https://golang.org/doc/install/source
- Go is compiled with … Go! I need to decide if I want to bootstrap a go compiler, or use the Go that’s already on my computer. I’m lazy so I’m going with the latter.
$GOROOT_BOOTSTRAPis an environment variable that must be set to the location of the Go compiler that I want to use. Since I’m using the regular Go installation that I already had on my mac, I set it using
export GOROOT_BOOTSTRAP=$(go env GOROOT). I tested that out by running
$GOROOT_BOOTSTRAP/bin/goand making sure I saw the Go help text.
- Clone the Go source code
git clone https://go.googlesource.com/go. I am not sure if it needs to be in the GOPATH or not (I’m assuming no?).
- Change to the go source and run
git tagto admire how many tags there are and see what version I can start building off of. I picked the latest
git checkout go1.11beta1.
- Change to the
src/dir in the repo and then run
./all.bash. Immediately regret deciding to do this on my mac book air.
- One of the tests failed, for
os/signalwith some odd timeouts. I’m going to blame that on my old laptop and hope for the best!
- Since the test failed, I am bypassing them and just doing a build+install with
- Switch my current shell session from using a stable go to the one I just built
$ go version go version go1.10 darwin/amd64 $ which go /usr/local/go/bin/go $ export PATH=/Users/carolynvs/src/go/bin:$PATH $ which go /Users/carolynvs/src/go/bin/go $ go version go version devel +a12c1f26e4 Tue Jun 26 20:00:51 2018 +0000 darwin/amd64
- OK, now how do I tweak it so that the new vgo prototype capabilities are enabled? Found the Pull Request (Google likes to call them CL’s) here: https://go-review.googlesource.com/c/go/+/118095
… a brief interlude while I enjoy my weekend …
Weather update: it’s still way too hot in Chicago, so the hacking continues!
So I’ve learned that the vgo prototype was merged into upstream Go, but it’s turned off. I’ve made a branch with it turned back on. The prototype’s code lives in
src/cmd/go/internal/vgo and hasn’t yet been fully hooked up to all the commands. Seems like
go build works, and uses the prototype, but stuff like
go list -m isn’t wired up yet.
I made a sample repo to try out my spiffy local build of Go. The
go.mod file exists to indicate to go that we want to use all the cool new stuff. I left it empty so that when I run
go build that it will detect my dependencies and populate the file for me.
$ go run main.go vgo: resolving import "github.com/pkg/errors" vgo: finding github.com/pkg/errors (latest) vgo: adding github.com/pkg/errors v0.8.0 hello world!
We’ve built Go from source, edited the source code to enable the vgo prototype, tweaked our PATH so that we can try out our custom build, and seen some output that makes me think I did that right.