exitwithstatus

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2018 License: ISC Imports: 3 Imported by: 7

README

exitwithstatus - Non-zero exit status

A way to provide a non-zero exit code from a program as Go does not support this directly.

Documentation

Overview

replacement for os.Exit(N) that runs defers

Original article: http://soniacodes.wordpress.com/2011/04/28/deferred-functions-and-an-exit-code/

This is modified version to pass an integer status to os.Exit

usage: as the first line of main add:

defer exitwithstatus.HandleFatal()

to exit with a particular integer value:

exitwithstatus.Exit(42)

Index

Constants

View Source
const (
	Major   = "0"
	Minor   = "1"
	Patch   = "2"
	Version = Major + "." + Minor + "." + Patch
)

ensure that git has a tag: "vX.Y.Z" corresponding to major, minor and patch

Variables

This section is empty.

Functions

func Exit

func Exit(status int)

Exit with the integer status value

e.g to exit calling all defers with the value three: exitwithstatus.Exit(3)

func Handler

func Handler()

This must be the first defer in the program

i.e. the first line of main must be: defer exitwithstatus.Handle()

func Message

func Message(message string, args ...interface{})

print a message to stderr and exit wit error status

Types

This section is empty.

Jump to

Keyboard shortcuts

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