Skip to content

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.

To install, grab the package from GitHub:

Terminal window
go get github.com/honeybadger-io/honeybadger-go

Then add an import to your application code:

import "github.com/honeybadger-io/honeybadger-go"

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.

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...
}

To report an error manually, use honeybadger.Notify:

if err != nil {
honeybadger.Notify(err)
}

See Reporting errors for more details.

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.