Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
Version, Build string
Description string
)
These var should be set externally by the build command
Functions ¶
func Conf ¶ added in v2.0.4
func Conf(cfg interface{}, path string)
Conf populates a json object applying tag:default conf values that are overloaded by the file source when configured at the primary level; no recurrsion support
type Example struct {
Text string `json:"text,omitempty"`
Number int `json:"number,omitempty" default:"10"`
Show bool `json:"show,omitempty" default:"on"`
}
supports: string, int, bool
func Dir ¶
Dir will create the directory tree when it does not exist and return a string representation of the full composite path. A file is presumed when the last element contains any of the following ._- characters and fs.FileMode is coded to 0755
func NewGraceful ¶
func NewGraceful() *graceful
NewGraceful configurator returns *graceful and starts a shutdown controller to capture (os.Interrupt, syscall.SIGTERM, syscall.SIGHUP) signals and waits on the <-g.context for a termination signal and waits for the g.init, g.shutdown controller shutdown to confirm all managed processes have completed tasks before the program terminates execution
func Shutdown ¶
Shutdown waits on control context.Context or signal.Notify; only use this when env.Graceful is not used; shutdownFunc will execute after a system or user signal is received (can be nil), however when a context.CancelFunc acutally needs to be called before exiting (or anything else for control purposes) then pass these items wrapped as the shutdownFunc; uses os.Exit(0)
ctx, cancel:= context.WithCancel(context.Backgroud())
env.Shutdown(ctx, func(){cancel()})
Types ¶
type Expire ¶
type Expire struct {
Freq time.Duration // frequency of checks (default: hourly)
// contains filtered or unexported fields
}
Expire struct
func (*Expire) Add ¶
Add will register a directory/path with customized age timeframe and supports various ttl inputs
nil default 24h int n * hour string "24h", "1h30m"
type Lock ¶
Lock {file}.lock detection
type Options ¶ added in v2.0.4
type Options struct {
Silent bool // silence log configuration output
NoHelp bool // silence help output
SetENV bool // set KEY=VALUE in environment
NoExit bool // return nil instead of os.Exit(0) for version,help
}
Options for env.Configure
Silent: log configuration output NoHelp: silences the help output SetENV: set KEY=VALUE in environemnt
type Path ¶ added in v2.0.4
type Path struct {
Etc, Srv, Var, Tmp string
}
Path type returned by NewENV and Configure
func Configure ¶ added in v2.0.4
func Configure(cfg ...interface{}) (path *Path)
Configure sets up the basic environment and returns environment paths; pass Options as the first item to set or specify custom configuration options to silence log and help output and env.Options.M map populates, struct initially, overloaded by environment vars, overloaded by default tag, that is then overloaded by command line swithches, in this order
func NewEnv ¶
func NewEnv(cfg ...interface{}) (path *Path)
NewEnv that sets up the basic envrionment paths and calls the Parser to process the struct tag fields and populates any interfaces that are provided
tags env:"alias,order,require,environ,hidden" help:"description" default:"value" (bool, string, int) Action string `env:"A,require" default:"server" help:"action [server|client]"`