Life In The Stack Trace...

TODO: <Insert clever marketing phrase here>

Running Godoc On Ubuntu As A Service

I'm digging Golang more and more each day and the godoc tool is proving quite useful. If you plan to release your code into the wild and have it show up in the public godoc at:, then, it is probably a good idea to attempt to provide documentation that is as complete as possible.

I especially like the fact that it is possible to host godoc on my local machine and it is searchable. Also, I like the fact that the doc from your current installation on your local machine can be included with all of the doc from your own projects. Awesome!

Running godoc as a service on Ubuntu is easy using Upstart. You should be able to use the following code to have godoc running on your local machine in no time.

1. create a file for the upstart service

   (you can use your own name if you want)
   at: /etc/init/godoc.conf

2. copy and paste the following into that file

   description "godoc server localhost"

   start on (local-filesystems and net-device-up and runlevel [2345])
   stop on runlevel [016]

   # Automatically Respawn:
   respawn limit 3 30


     exec /bin/bash <<'EOT'

       export GOROOT="/usr/local/go"
       export GOPATH="<insert your GOPATH here"

       exec /usr/local/go/bin/godoc -index -http=:6060


   end script

3. make sure to change the GOPATH to match your current
   GOPATH environment setting.

4. start the service: sudo service godoc start

5. http://localhost:6060

You should now have godoc running on your local machine!!

Another thing I really like is that you can make changes to the doc within your source code, save, and hit refresh and the changes will appear.