Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Building Go

Graham MacDonald edited this page Sep 14, 2020 · 2 revisions

To build and run go in Harvey, follow these steps below. In these steps, we specify the last known good version of go that the team uses. As Harvey uses the Plan 9 build, and Plan 9 does not have first line support in Go, there's always a chance a more recent build won't work. Note that we clone into a folder called golang because the Harvey project has its own go git repo, for the code written in go.

Cross Compiling Go

  1. git clone [email protected]:golang/go.git golang
  2. cd golang
  3. git checkout --track origin/release-branch.go1.15
  4. cd src
  5. GOOS=plan9 GOARCH=amd64 ./bootstrap.bash

You now have a folder named ../../go-plan9-amd64-bootstrap and the bzip tar file ../../go-plan9-amd64-bootstrap.tbz. The next step is to copy the folder to Harvey (again on the host):

  1. mkdir -p $HARVEY/plan9_amd64/bin
  2. mv ../../go-plan9-amd64-bootstrap $HARVEY/plan9_amd64/bin/go

Building with Go in Harvey Now we're ready to build some go in Harvey. So bring up Harvey and run the commands below.

To set up go (you may want to add this to your profile).

  1. bind -a /plan9_amd64/bin/go/bin /bin
  2. GOROOT=/plan9_amd64/bin/go

Now to build a simple go program:

  1. Copy the hello world program here into hello.go
  2. Build: GO111MODULE=off go build hello.go
  3. Run: ./hello.go

Congratulations - you've built and run your first go program in Harvey.