Skip to content

Instantly share code, notes, and snippets.

@prestonp
Last active March 19, 2021 08:07
Show Gist options
  • Save prestonp/d50c3282d859fa344a02e76520ea55f9 to your computer and use it in GitHub Desktop.
Save prestonp/d50c3282d859fa344a02e76520ea55f9 to your computer and use it in GitHub Desktop.
Run godoc in the background with launchd on osx
<?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>EnvironmentVariables</key>
<dict>
<!-- set your gopath -->
<key>GOPATH</key>
<string>/Users/ppham/go</string>
</dict>
<key>ProgramArguments</key>
<array>
<!-- ensure this is the absolute path to your godoc install -->
<string>/usr/local/go/bin/godoc</string>
<string>-http=localhost:6060</string>
</array>
<key>RunAtLoad</key>
<true/>
<!-- optional logging -->
<key>StandardErrorPath</key>
<string>/tmp/godocd.err</string>
<key>StandardOutPath</key>
<string>/tmp/godocd.out</string>
</dict>
</plist>

Add ~/Library/LaunchAgents/org.golang.godoc.plist and modify the GOPATH environment var and godoc path

Then run

launchctl load ~/Library/LaunchAgents/org.golang.godoc.plist

Then navigate to localhost:6060 to see godocs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment