sysexits

package
v0.0.0-...-af7b024 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2020 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Overview

Package sysexits provides exit status codes for system programs.

This package is based on errors provided in `/usr/include/sysexits.h`.

The following example calls os.Exit with an OK (0) exit code.

```go package main

import (

"os"
"github.com/kward/golib/os/sysexits"

)

func main() {
	fmt.Println("Hello, world!")
	os.Exit(sysexits.OK.Int())
}

```

The following code snippet exits with a Software (70) error code. Note that os.Exit is implicitly called by Exitf.

```go package main

import (

"github.com/kward/golib/os/sysexits"

)

func main() {
	sysexits.Exitf("some error", sysexits.Software)
}

```

Index

Constants

View Source
const (
	Max Code = Config // Maximum listed value.

	// Aliases for compatibility.
	DataErr   = DataError
	OSErr     = OSError
	CantCreat = CantCreate
	IOErr     = IOError
	TempFail  = TempFailure
	NoPerm    = NoPermission
)

Variables

This section is empty.

Functions

func Exit

func Exit(code int)

Exit calls os.Exit with the given code.

func Exitf

func Exitf(code int, format string, args ...interface{})

Exitf prints a message to STDERR and calls Exit with the given code.

Types

type Code

type Code int

Code is an error code for os.Exit().

const (
	OK   Code = 0  // Successful termination.
	Base      = 64 // Base value for error messages.
)
const (
	Usage        Code = iota + Base // Command-line usage error.
	DataError                       // Data format error.
	NoInput                         // Cannot open input.
	NoUser                          // Addressee unknown.
	NoHost                          // Host name unknown.
	Unavailable                     // Service unavailable.
	Software                        // Internal software error.
	OSError                         // System error (e.g., can't fork).
	OSFile                          // Critical OS file missing.
	CantCreate                      // Can't create (user) output file.
	IOError                         // Input/output error.
	TempFailure                     // Temp failure; user is invited to retry.
	Protocol                        // Remote error in protocol.
	NoPermission                    // Permission denied.
	Config                          // Configuration error.
)

func (Code) Int

func (c Code) Int() int

Int returns the int value of the code.

func (Code) String

func (i Code) String() string

Jump to

Keyboard shortcuts

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