Server SDK

Error monitoring for Go

A small library with a net/http middleware, a manual `Notify()` call, and a `Recover()` helper for background goroutines. Explicit by design — you decide what gets captured.

Frameworks net/httpRequires Go 1.22+Package github.com/errorgaphq/errorgap-goSource ↗Package ↗Agent guide ↗
Install

Install

sh
go get github.com/errorgaphq/errorgap-go
Configure

Configure

Initialize early in main and defer a clean shutdown so buffered events flush:

go
import (
    "context"
    "os"

    errorgap "github.com/errorgaphq/errorgap-go"
)

func main() {
    if err := errorgap.Init(errorgap.Config{
        Endpoint:    os.Getenv("ERRORGAP_ENDPOINT"),
        ProjectSlug: os.Getenv("ERRORGAP_PROJECT_SLUG"),
        APIKey:      os.Getenv("ERRORGAP_API_KEY"),
    }); err != nil {
        panic(err)
    }
    defer errorgap.Close(context.Background())
    // ...
}

Wrap a net/http server with the recovery middleware:

go
import "github.com/errorgaphq/errorgap-go/stdhttp"

http.ListenAndServe(":8080", stdhttp.Recover(mux))

And guard background goroutines with Recover():

go
go func() {
    defer errorgap.Recover()
    // ... work ...
}()
Keep the key in an environment variable (or your framework's secret store) — never commit it to source control.
Trigger a test error

Trigger a test error

Add a temporary route that panics through the recover handler:

go
mux.HandleFunc("/errorgap-test", func(w http.ResponseWriter, r *http.Request) {
    panic("Errorgap test error")
})
Verify

Verify the connection

Confirm your key and endpoint reach errorgap before wiring anything else — send one event straight to the ingestion API:

bash
curl -sS -X POST "$ERRORGAP_ENDPOINT/api/projects/$ERRORGAP_PROJECT_SLUG/notices" \
  -H "content-type: application/json" \
  -H "x-errorgap-project-key: $ERRORGAP_API_KEY" \
  -d '{"errors":[{"type":"ErrorgapInstallTest","message":"Errorgap install verification"}]}'

A 201 with a group_id means ingestion works (202 = received but sampled; 401 = wrong key). Then trigger the test error above through the SDK. Your onboarding screen's Verify step checks the stack off automatically once the first event lands — it polls every three seconds.

Next: the full ingestion API, or browse every SDK.