atexit

package module
v0.0.0-...-8a6ce23 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2019 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Git Mirror of https://bitbucket.org/tebeka/atexit

========================

About
=====
Simple `atexit` implementation for Go_.

Note that you *have* to call `atexit.Exit` and not `os.Exit` to terminate your
program (that is, if you want the `atexit` handlers to execute).

Example usage
=============
::

    package main

    import (
        "atexit"
        "fmt"
    )

    func handler() {
        fmt.Println("Exiting")
    }

    func main() {
            atexit.Register(handler)
            atexit.Exit(0)
    }

Install
=======
::

    goinstall bitbucket.org/tebeka/atexit

Contact
=======
Home
    https://bitbucket.org/tebeka/atexit
Author
    Miki Tebeka <miki.tebeka@gmail.com>


.. _Go: http://golang.org

Documentation

Overview

Simple atexit implementation. Add handlers using Register, you must call

atexit.Exit to get the handler invoked (and then terminate the program).

This package also provides replacements to log.Fatal, log.Fatalf and log.Fatalln.

Example:

package main

import (
    "atexit"
    "fmt"
)

func handler() {
    fmt.Println("Exiting")
}

func main() {
        atexit.Register(handler)
        atexit.Exit(0)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exit

func Exit(code int)

Exit runs all the atexit handlers and then terminates the program using os.Exit(code)

func Fatal

func Fatal(v ...interface{})

Fatal runs all the atexit handler then calls log.Fatal (which will terminate the program)

func Fatalf

func Fatalf(format string, v ...interface{})

Fatalf runs all the atexit handler then calls log.Fatalf (which will terminate the program)

func Fatalln

func Fatalln(v ...interface{})

Fatalln runs all the atexit handler then calls log.Fatalln (which will terminate the program)

func Register

func Register(handler func())

Add atexit handler, call atexit.Exit to invoke all handlers.

Types

This section is empty.

Jump to

Keyboard shortcuts

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