atexit

package
v0.3.11-8 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: Apache-2.0 Imports: 8 Imported by: 27

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exit

func Exit(code int)

Exit calls handlers then does os.Exit(code)

func Handle

func Handle()

Handle calls registered handlers sequentially according to priority and registration order

Panics caused by handler func will be caught, recorded, then next func will be run

func Register

func Register(eh ExitHandler)

Register registers ExitHandler

Smaller prio number mean higher priority and exit handlers with higher priority will be executed first. For handlers with equal priorities, those registered first will be executed earlier at exit time

Types

type ExitHandler

type ExitHandler struct {
	Prio   Prio
	Reason string
	Func   ExitHandlerFunc
	Value  interface{}
}

ExitHandler defines the spec of handler

Reason and Func are mandatory and must not be empty or nil

Handlers with smaller Prio will be executed earlier than those with bigger Prio at exit time. Handler func will receive a copy of the ExitHandler struct previously registered

type ExitHandlerFunc

type ExitHandlerFunc func(ExitHandler)

ExitHandlerFunc is the type of handler func

type Prio

type Prio int
const (
	PRIO_LOG_OTHER Prio = 20000
	PRIO_LOG_CLOSE Prio = 40000
)

Jump to

Keyboard shortcuts

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