John Floren

Home | Blog
Back to blog archive

Posted 2012/3/27

Using Go RC1

I finally got around to setting up Go RC1 on my work laptop. It’s significantly better than the earlier versions in terms of setting things up. The tools are also pretty slick at this point.

Although checking out the source via Mercurial is still an option, the installation instructions now tell you to download a tarball. Either way, you put the Go tree in /usr/local/go; in the case of a tarball, everything is already built, so once you set your PATH to include /usr/local/go/bin, you’re set.

You no longer have to write a Makefile. Compiling a command is easy–just write your code (put the code in the “main” package to make it a command) and run “go build .”. This will build your code automatically.

Creating a package or installing packages from an online repository is pretty easy too. You need to make a directory somewhere (I used /home/john/mygo) and define the GOPATH environment variable to point to it. If you need to install a package from the Internet (for example, github.com/floren/ellipsoid), simply run “go install github.com/floren/ellipsoid” and it will download, compile, and install the package in the appropriate place in your GOPATH. If you want to write a new package, place it under $GOPATH/src, example $GOPATH/src/bitbucket.org/floren/newpackage, and run “go install .” in that directory.

I updated a big chunk of my code to Go RC1. It was a reasonably painless process, but one major thing to look out for: you no longer need to define GOROOT. If you do, define it to /usr/local/go, not /home/john/mygo or whatever you select as your GOPATH.