godoc
is an amazing reference utility. I use launchd
to keep it running for me.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>org.golang.godoc</string> <key>ProgramArguments</key> <array> <!-- ensure this is the absolute path to your godoc install --> <string>/Users/dave/go/bin/godoc</string> <string>-http=127.0.0.1:6060</string> </array> <key>Sockets</key> <dict> <key>Listeners</key> <dict> <key>SockServiceName</key> <string>6060</string> </dict> </dict> <key>RunAtLoad</key> <false/> </dict> </plist>
Place this file in ~/Library/LaunchAgents/org.golang.godoc.plist
and edit the absolute path to your godoc
binary. Then issue the command
$ launchctl load ~/Library/LaunchAgents/org.golang.godoc.plist
You can then browse to http://127.0.0.1:6060
to view the current documentation for your Go installation.
To stop godoc
just issue a killall godoc
and launchd
will restart it when necessary. You can use the same command after updating to the latest release to ensure you’re viewing the most up to date documentation.