Help us shape the future of Go! Take the 2026 Go Developer Survey

callback

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package callback isolates extension failures without formatting panic payloads.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorAs

func ErrorAs(err error, target any) bool

ErrorAs publishes a match only after inspection returned normally. The target is untouched on panic, Goexit, exhaustion, a nonmatch or a nil match. A nil detail cannot establish a framework classification.

func ErrorAsResult

func ErrorAsResult(err error, target any) (bool, error)

ErrorAsResult publishes a match only after completed inspection, and retains failed inspection separately so callers cannot normalize it as bad input.

func ErrorIs

func ErrorIs(err, target error) bool

ErrorIs bounds and contains application matching methods. Incomplete or failed inspection establishes no match; the original error remains a failure.

func ErrorIsResult

func ErrorIsResult(err, target error) (matched bool, failed error)

ErrorIsResult distinguishes a completed nonmatch from failed inspection.

func ErrorWalk

func ErrorWalk(err error, visit func(error) bool) bool

ErrorWalk contains a bounded graph walk. Visitors must treat their collected results as provisional until this returns true.

func Invoke

func Invoke(operation string, fn func() error) (err error)

Invoke catches panics and preserves ordinary callback error identity. runtime.Goexit still exits this goroutine; use Isolated when it must be caught. A contained panic keeps its source frames, never its recovered value.

func Isolated

func Isolated(operation string, fn func() error) error

Isolated runs a callback in an owned goroutine and waits for its actual exit. It catches Goexit as well as panic. It never abandons an uncooperative callback or claims its resources have been released when it is still running.

func RetainDiagnostic

func RetainDiagnostic(foreign, result error) error

RetainDiagnostic recovers a source-issued immutable marker hidden by a foreign wrapper after the foreign operation finishes. Inspection is bounded and contained; it never formats errors or opens opaque application capsules. The complete result, including outcome and cleanup causes, is preserved.

func Returned

func Returned(operation string, err error) error

Returned applies Invoke's error policy after a trusted framework callback. It never inspects or formats application causes. Fast paths call it only when a failure occurs, retaining the same diagnostic and classification as Invoke.

Types

This section is empty.

Jump to

Keyboard shortcuts

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