debug

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Tag is a compile-time variable
	Tag = "development"
	// Package is a compile-time variable
	Package = "gotui"
	// Commit is a compile-time variable
	Commit = "HEAD"
	// ReportsDir is a compile-time variable.
	// If left empty, debug helpers will use the return
	// of os.TempDir.
	ReportsDir = ""
)

Functions

func CapturePanicReport

func CapturePanicReport(fn func())

CapturePanicReport captures a panic with CapturePanicReportWith, and exits or simply returns if there was no panic in fn. It uses the compile-time variables Tag, Package and ReportsDir, so make sure they're injected at compile-time when using this helper.

func CapturePanicReportWith

func CapturePanicReportWith(dir, pkg, version string, run func()) (
	panicValue any, err error, ok bool,
)

CapturePanicReportWith captures a panic in fn and writes to disk a yaml report. The boolean value returned indicates if fn run with no panics. If the value is false, the returned string indicates the fs location of the report. An error is returned if there was a panic but the report couldn't be stored.

Types

type Report

type Report struct {
	Package   string
	Version   string
	Author    string
	Subject   string
	Notes     string
	Build     debug.BuildInfo `yaml:"build,omitempty"`
	CreatedAt time.Time       `yaml:"created_at,omitempty"`
	UpdatedAt time.Time       `yaml:"updated_at,omitempty"`
	UpdatedBy string          `yaml:"-"`
	Closed    bool            `yaml:"closed,omitempty"`
	ClosedAt  time.Time       `yaml:"closed_at,omitempty"`
	Metadata  map[string]string
}

Report contains information about a suspected or confirmed bug.

func BuildCrashReport

func BuildCrashReport(pkg, version string, panicValue any) (
	report Report,
)

BuildCrashReport builds a crash report with the given panic value, for the given package and version.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL