Skip to content

About

The Bugstack SDK for Go. Reports panics and errors from net/http, Gin and Echo to Bugstack, autonomous software maintenance.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

bugstack-go

The Bugstack SDK for Go: net/http, Gin and Echo.

Bugstack is autonomous software maintenance. It watches your app and your repository, fixes what breaks, and sends every change as a pull request you control. This SDK is how your server tells Bugstack about a panic or an error.

Go Reference License: MIT

Installation

go get github.com/MasonBachmann7/bugstack-go

Quick Start

package main

import (
    "errors"
    bugstack "github.com/MasonBachmann7/bugstack-go"
)

func main() {
    bugstack.Init(bugstack.Config{
        APIKey: "bs_live_...",
    })
    defer bugstack.Flush()

    err := riskyOperation()
    if err != nil {
        bugstack.CaptureError(err)
    }
}

Panic Recovery

func handler() {
    defer bugstack.Recover()
    // ... code that might panic
}

HTTP Middleware

net/http

import "github.com/MasonBachmann7/bugstack-go/middleware"

mux := http.NewServeMux()
mux.HandleFunc("/", handler)
http.ListenAndServe(":8080", middleware.NetHTTP(mux))

Gin

import "github.com/MasonBachmann7/bugstack-go/middleware"

r := gin.Default()
r.Use(gin.HandlerFunc(middleware.GinRecovery()))

Echo

import "github.com/MasonBachmann7/bugstack-go/middleware"

e := echo.New()
e.Use(echo.MiddlewareFunc(middleware.EchoRecover()))

Configuration

bugstack.Init(bugstack.Config{
    APIKey:              "bs_live_...",       // Required
    Environment:         "production",       // Default: "production"
    AutoFix:             true,               // Let Bugstack open a fix for errors this SDK reports
    Debug:               false,              // Log SDK activity
    DryRun:              false,              // Log without sending
    Enabled:             true,               // Kill switch
    DeduplicationWindow: 300,                // Seconds (default: 5 min)
    Timeout:             5.0,                // HTTP timeout in seconds
    MaxRetries:          3,                  // Retry attempts
    IgnoredErrors:       []string{           // Error substrings to skip
        "context canceled",
    },
    BeforeSend: func(e *bugstack.Event) *bugstack.Event {
        // Return nil to drop, modify and return to keep
        return e
    },
})

Data Transparency

BeforeSend Hook

Inspect, modify, or drop any event before it leaves your application:

bugstack.Init(bugstack.Config{
    APIKey: "bs_live_...",
    BeforeSend: func(e *bugstack.Event) *bugstack.Event {
        if e.Request != nil && e.Request.Route == "/health" {
            return nil // Drop health check errors
        }
        delete(e.Metadata, "secret")
        return e
    },
})

DryRun Mode

See exactly what would be sent without network requests:

bugstack.Init(bugstack.Config{
    APIKey: "bs_live_...",
    DryRun: true,
})
// Prints: [BugStack DryRun] Would send: { ... }

What Gets Sent

{
  "apiKey": "bs_live_...",
  "error": {
    "message": "runtime error: index out of range",
    "stackTrace": "goroutine 1 [running]: ...",
    "file": "main.go",
    "function": "main.handler",
    "fingerprint": "a1b2c3d4e5f6g7h8"
  },
  "environment": {
    "language": "go",
    "languageVersion": "go1.22.0",
    "os": "linux",
    "sdkVersion": "1.0.0"
  },
  "timestamp": "2026-01-15T08:30:00Z"
}

Zero external dependencies. No cookies, IP addresses, or user data collected.

License

MIT — see LICENSE.

About

The Bugstack SDK for Go. Reports panics and errors from net/http, Gin and Echo to Bugstack, autonomous software maintenance.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages