cmdline

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2019 License: MIT Imports: 5 Imported by: 3

Documentation

Overview

Contains common structure handles errors in CausedBy way in command line utility applications.

Service/daemon can use cmdline package to handle main goroutine's panic/errors, but can not handle panic/errors inside other goroutines, use redforks/life package to cover service goroutines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Go

func Go(main MainFunc)

Call your application main function, handles any error returned or paniced, handle error by errors.CausedBy rule.

func NewExitError

func NewExitError(code int) error

Create a new exit error. Panic with exit error or return it in MainFunc, Go() detect it and call os.Exit() with specific exit code. os.Exit() exit the application immediately without calling deferred code block, by using exit error we can *fix* this.

Types

type MainFunc

type MainFunc func() error

Your application main function type.

Jump to

Keyboard shortcuts

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