atexit

package
v0.0.0-...-bfb01ae Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2017 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Overview

Package atexit implements a simple atexit library.

Example:

package main

import (
	"fmt"

	"bitbucket.org/JeremySchlatter/go-atexit"
)

func main() {
	atexit.TrapSignals()
	defer atexit.CallExitFuncs()

	atexit.Run(func() {
		fmt.Println("exited")
	})
}
Example
defer CallExitFuncs()
Run(func() {
	fmt.Println("End")
})
Run(func() {
	fmt.Println("Middle")
})
fmt.Println("Beginning")
Output:

Beginning
Middle
End

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallExitFuncs

func CallExitFuncs()

CallExitFuncs calls all functions previously registered through Run, in reverse order.

func Run

func Run(f func())

Run registers the function f to be called at the program's exit.

func TrapSignals

func TrapSignals()

TrapSignals registers a handler for SIGINT and SIGTERM that calls CallExitFuncs() followed by os.Exit(1).

Types

This section is empty.

Jump to

Keyboard shortcuts

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