Other Go applications
Typical installation time: 5 minutes
Hi there! You’ve found Honeybadger’s guide to Go error tracking for standalone applications, CLI tools, workers, and other non-HTTP Go programs. Once installed, Honeybadger will report panics and errors from your application.
Installing the package
Section titled “Installing the package”To install, grab the package from GitHub:
go get github.com/honeybadger-io/honeybadger-goThen add an import to your application code:
import "github.com/honeybadger-io/honeybadger-go"Configuring your API key
Section titled “Configuring your API key”Configure your API key using honeybadger.Configure:
honeybadger.Configure(honeybadger.Configuration{APIKey: "PROJECT_API_KEY"})You can also configure Honeybadger via the HONEYBADGER_API_KEY environment
variable. See Configuration for more
options.
Enabling automatic panic reporting
Section titled “Enabling automatic panic reporting”To report all unhandled panics which happen in your application, add the
following to main():
func main() { defer honeybadger.Monitor() // application code...}Important: honeybadger.Monitor() will re-panic after it reports the error,
so make sure that it is only called once before recovering from the panic (or
allowing the process to crash).
You can also monitor specific functions:
func risky() { defer honeybadger.Monitor() // risky business logic...}Manually reporting errors
Section titled “Manually reporting errors”To report an error manually, use honeybadger.Notify:
if err != nil { honeybadger.Notify(err)}See Reporting errors for more details.
Testing your installation
Section titled “Testing your installation”To verify that your installation is working, you can add a test panic:
func main() { defer honeybadger.Monitor() panic("Testing Honeybadger!")}Run your application, then check your Honeybadger dashboard for the error.
Next steps
Section titled “Next steps”- Learn how to report errors manually
- Add context to your errors
- Explore configuration options