app

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2019 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Arguments   []string        // Command Line arguments
	Environment []string        // OS Environment Variables
	Context     context.Context // Application context
	Stdin       io.Reader       // fd0 /dev/stdin
	Stdout      io.Writer       // fd1 /dev/stdout
	Stderr      io.Writer       // fd2 /dev/stderr
	ExitHandler func(int)       // handler for calls to os.Exit
	// contains filtered or unexported fields
}

App represents a core application instance. Values can be mocked for testing.

func New

func New() *App

New returns a new App instance. The values are take directly from the environment. Manually construct an App instance in order to mock these values.

func (*App) Errors

func (a *App) Errors() <-chan error

Errors returns the error channel for this app.

func (*App) Exit

func (a *App) Exit(code int)

Exit calls the app ExitHandler. If no ExitHandler is set, calls os.Exit. This method properly shuts down the app logger if it has been initialized.

func (*App) HandleError

func (a *App) HandleError(err error)

HandleError sends the supplied error via the Errors channel. The channel is closed after sending.

func (*App) Logger

func (a *App) Logger() *gomol.Base

Logger returns a cached logger instance. ShutdownLoggers must be called on the logger before terminating the app.

func (*App) LookupEnv

func (a *App) LookupEnv(key string) (string, bool)

LookupEnv searches the app environment variables for the specified key. If the key is found, returns a tuple of the value and true. If not found, returns the zero string and false.

Jump to

Keyboard shortcuts

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