{ "html": "
\n

Installation

\n

Raven-Go can be installed like any other Go library through go get:

\n
$ go get github.com/getsentry/raven-go\n
\n
\n
\n\n\n
\n

Configuring the Client

\n

To use raven-go, you’ll need to import the raven package, then initilize your\nDSN globally. If you specify the SENTRY_DSN environment variable, this will be\ndone automatically for you.

\n
package main\n\nimport "github.com/getsentry/raven-go"\n\nfunc init() {\n    raven.SetDSN("___DSN___")\n}\n
\n
\n
\n\n\n
\n

Reporting Errors

\n

In Go, there are both errors and panics, and Raven can handle both. To learn more\nabout the differences, please read Error handling and Go.

\n

To handle normal error responses, we have two options: CaptureErrorAndWait and CaptureError. The former is a blocking call, for a case where you’d like to exit the application after reporting, and the latter is non-blocking.

\n
f, err := os.Open("filename.ext")\nif err != nil {\n    raven.CaptureErrorAndWait(err, nil)\n    log.Panic(err)\n}\n
\n
\n
\n\n\n
\n

Reporting Panics

\n

Capturing a panic is pretty simple as well. We just need to wrap our code in CapturePanic. CapturePanic will execute the func and if a panic happened, we will record it, and gracefully continue.

\n
raven.CapturePanic(func() {\n    // do all of the scary things here\n}, nil)\n
\n
\n
\n", "link": "https://docs.getsentry.com/clients/go/", "id": "go", "name": "Go" }