/ golang

godoc with homebrew installed Go

This is basically the same information as you would get if you RTFM[1]. When you install Go from Homebrew, it doesnʼt include godoc which, is pretty annoying. The smart thing to do here would be to RTFM but, I didnʼt. Iʼm guessing that a bunch of other people wont as well. You can Google for the problem but, it doesnʼt immediately come up with a solution for the problem. So lets get back to that RTFM thing again.

➜  ruin-jekyll git:(master) ✗ brew info go
go: stable 1.3.1 (bottled), HEAD
http://golang.org
/usr/local/Cellar/go/1.3.1 (4343 files, 135M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/go.rb
==> Options
--cross-compile-all
        Build the cross-compilers and runtime support for all supported platforms
--cross-compile-common
        Build the cross-compilers and runtime support for darwin, linux and windows
--without-cgo
        Build without cgo
--HEAD
        install HEAD version
==> Caveats
As of go 1.2, a valid GOPATH is required to use the `go get` command:
  http://golang.org/doc/code.html#GOPATH

`go vet` and `go doc` are now part of the go.tools sub repo:
  http://golang.org/doc/go1.2#go_tools_godoc

To get `go vet` and `go doc` run:
  go get code.google.com/p/go.tools/cmd/godoc
  go get code.google.com/p/go.tools/cmd/vet

You may wish to add the GOROOT-based install location to your PATH:
  export PATH=$PATH:/usr/local/opt/go/libexec/bin

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completion has been installed to:
  /usr/local/share/zsh/site-functions

So, to install godoc, set your $GOPATH and then run go get code.google.com/p/go.tools/cmd/godoc. Seems pretty simple right? Except, were is godoc? It isnʼt at $GOTPATH/bin. Turns out that it gets installed into goroot. Youʼll also need to add /usr/local/opt/go/libexec/bin to your path. So, the 3 steps that need to be completed are:

  1. Make sure that your $GOPATH is set already
  2. run go get code.google.com/p/go.tools/cmd/godoc
  3. add export PATH=$PATH:/usr/local/opt/go/libexec/bin somewhere in your dot files.

  1. Read the Fucking Manual, for those of you that donʼt know. ↩︎