Installing with the CLI
The Airbrake CLI installs the Airbrake Go notifier automatically in your Go project. To install the notifier directly without using the CLI, please scroll down to the Installing manually section.
Install the CLI via Homebrew
brew install airbrake/airbrake-cli/airbrake
Authenticate via config
command
Authenticate by setting your user-key
with the config
command:
airbrake config set user-key YOUR_USER_KEY_HERE
Install command
Invoke the following to have the Airbrake CLI install the Airbrake notifier for your project:
airbrake install --project-id 495447
After this, you are set! Check out the Testing your installation section to send a test error to Airbrake.
Installing manually
Install in existing project
Navigate to your project's main directory and install our Go package, gobrake
:
go get github.com/airbrake/gobrake/v5
Install in new app
Create a new directory, initialize a new module and go get
the library:
mkdir airbrake_example && cd airbrake_example
go mod init airbrake_example
go get github.com/airbrake/gobrake/v5
Configuration
Import and initialize the gobrake
package in your application:
package main
import "github.com/airbrake/gobrake/v5"
var airbrake = gobrake.NewNotifierWithOptions(&gobrake.NotifierOptions{
ProjectId: 495447,
ProjectKey: "14108084f70144073cf58cc62ab733b8",
Environment: "production",
})
func main() {
defer airbrake.Close()
defer airbrake.NotifyOnPanic()
}
That's it! The airbrake.NotifyOnPanic()
call will handle automatic panic reporting.
Testing your installation
You can use airbrake.Notify()
to send handled errors. Let's use it now to check if gobrake
is installed correctly:
import "errors"
func testAirbrake() {
airbrake.Notify(errors.New("Error Test from Airbrake"), nil)
}
You should see this dashboard updating with your test error soon after you run that function.
Full documentation
Check out our official documentation for info on advanced features like ignoring errors, setting error severity and more.