The Easiest Way to Use Go from Source

Recently I saw someone suggest using the unreleased version of Go, without the magically easy way to do it. Here’s how.

First you need to install some version of Go. Use the version packaged with your Linux distribution; or if you are using OSX or RUNNING_IN_HELL use the officially packaged, latest release. Next you need to install gotip:

go get golang.org/dl/gotip

After that you need to tell it to install the current latest version:

gotip download

The above command takes a while; it downloads and installs everything you need and builds the latest unreleased version of go, called tip (like how the latest unreleased perl is called blead.)

After running the above command you can use gotip as if it were go. For example, if you ran it now you could see docs for the new errors package:

$ gotip doc errors
package errors // import "errors"

Package errors implements functions to manipulate errors.

func As(err error, target interface{}) bool
func Is(err, target error) bool
func New(text string) error
func Opaque(err error) error
func Unwrap(err error) error
type Formatter interface{ ... }
type Frame struct{ ... }
    func Caller(skip int) Frame
type Printer interface{ ... }
type Wrapper interface{ ... }

And you’d use gotip build, gotip test, and all the other stuff you are used to using with the go tool.

If interested, you can do the same thing for each version of go; see the docs here. I don’t know why I don’t see this mentioned more often. In the future I’m going to stop extracting the tarball and exclusively download this way and just create a ~/bin/go symlink to the latest version.


If you are interested in learning Go, this is my recommendation:

If you don’t already know Go, you should definitely check out The Go Programming Language. It’s not just a great Go book but a great programming book in general with a generous dollop of concurrency.

Another book to consider learning Go with is Go Programming Blueprints. It has a nearly interactive style where you write code, see it get syntax errors (or whatever,) fix it, and iterate. A useful book that shows that you don’t have to get all of your programs perfectly working on the first compile.

Posted Fri, May 3, 2019

If you're interested in being notified when new posts are published, you can subscribe here; you'll get an email once a week at the most.