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

panicguard

package
v1.126.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package panicguard runs background work in a goroutine with a recovery frame.

The gRPC recovery middleware only wraps the request handler's own stack. A goroutine spawned from a handler escapes it, so an unrecovered panic there terminates the whole process. Any request-spawned goroutine must therefore run through this package instead of a bare `go`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Go

func Go(logger *log.Helper, task string, fn func())

Go runs fn in a new goroutine with a recovery frame. A recovered panic is logged with its stack and swallowed so it cannot crash the process.

func Recover

func Recover(logger *log.Helper, task string, fn func())

Recover runs fn in the current goroutine with a recovery frame. It is the synchronous core of Go, exposed for callers that already own a goroutine and for tests.

Types

This section is empty.

Jump to

Keyboard shortcuts

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