Files
errors.bitreport.pt/clients/go/examples/basic_usage.go
David SantosandClaude Sonnet 4.6 da57d2a444 feat(clients): add Python, Go, and Java client libraries (BIT-14250)
Zero-dependency clients for errors.bitreport.pt following the same
patterns as clients/node and clients/php: batch size 25, 5 s flush
interval, 8 s HTTP timeout, fire-and-forget, env-var config.

Each client ships with unit tests backed by an embedded HTTP server
(no mocks), an example file, and a build manifest (pyproject.toml,
go.mod, pom.xml).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-04-27 10:08:11 +00:00

47 lines
996 B
Go

//go:build ignore
// Basic usage example for the BitReport Go error reporter.
//
// Run with:
//
// ERROR_REPORTING_TOKEN=your_token go run basic_usage.go
package main
import (
"errors"
"fmt"
"os"
errorreporter "pt.bitreport/errors-go"
)
func main() {
errorreporter.Init(errorreporter.Config{
Token: os.Getenv("ERROR_REPORTING_TOKEN"),
ProjectName: "My Go App",
ProjectSlug: "my-go-app",
})
defer errorreporter.Flush()
// Report a plain message
errorreporter.ReportMessage("Application started", "info", nil)
// Report a warning with extra context
errorreporter.ReportMessage("Cache miss", "warning", map[string]interface{}{
"cache_key": "user:42",
})
// Report an error
if err := riskyOperation(); err != nil {
errorreporter.ReportError(err, map[string]interface{}{
"operation": "riskyOperation",
})
}
fmt.Println("Events sent. Check your errors.bitreport.pt dashboard.")
}
func riskyOperation() error {
return errors.New("something went wrong")
}