//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") }