{% load i18n %}
Note: Just as Go is a fairly young language, the raven-go client is also fairly immature and may be missing features.
{% blocktrans with 'https://github.com/getsentry/raven-go' as link %}Start by installing raven-go.{% endblocktrans %}
go get github.com/getsentry/raven-go
Import the library:
import "github.com/getsentry/raven-go"
Next up create an instance of the client:
client, _ := raven.NewClient("{% if dsn %}{{ dsn }}{% else %}SENTRY_DSN{% endif %}", nil)
Now you're all set to capture an event client.CaptureError(myError, nil, nil)
A more in-depth example:
// ... i.e. raisedErr is incoming error
var raisedErr error
// sentry DSN generated by Sentry server
var sentryDSN string = "{% if dsn %}{{ dsn }}{% else %}SENTRY_DSN{% endif %}"
// r is a request performed when error occured
var r *http.Request
client, err := raven.NewClient(sentryDSN, nil)
if err != nil {
log.Fatal(err)
}
// create a stacktrace for our current context
trace := raven.NewStacktrace(0, 2, nil)
packet := raven.NewPacket(raisedErr.Error(), raven.NewException(raisedErr, trace), NewHttp(r))
eventID, ch := client.Capture(packet, nil)
if err = <-ch; err != nil {
log.Fatal(err)
}
message := fmt.Sprintf("Captured error with id %s: %q", eventID, raisedErr)
log.Println(message)
{% blocktrans with 'http://godoc.org/github.com/getsentry/raven-go' as link %}For more information on other uses of Raven with PHP, please see the official documentation for raven-go.{% endblocktrans %}