Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNilData = errors.New("nil data")
ErrNilData mean that exists nil pointer inside data struct
var FlagParsed func() error
FlagParsed define this callback when you need handle flags This callback will raise after method flag.Parse() return not nil error interrupt pasring
var IgnoreNilData = false
IgnoreNilData throw ErrNilData error if pointer(s) inside data struct is nil
var UseCustomHelp = true
UseCustomHelp override default flag `Usage`
Functions ¶
func Parse ¶
func Parse(data interface{}) error
Parse define variables inside data from different sources, such as flag/environment variable or default value
func ParseWithExternal ¶
ParseWithExternal works same as Parse method but also can be used external sources (config files, key-value storages, etc.).
func SetLogger ¶
func SetLogger(logger Logger)
SetLogger define debug logger. This logger will print setted values in data fields
func SetPriority ¶
func SetPriority(priority ...Priority)
SetPriority can override default priority queue. Default priority queue is: Flag, Environment variable, External source, Default value.
Types ¶
type External ¶
type External interface {
// Get string value from values chain(from parent to child)
Get(...Value) (interface{}, bool)
//
Unmarshal(interface{}) error
}
External config source
type JsonConfig ¶
type JsonConfig struct {
// contains filtered or unexported fields
}
func NewJsonConfig ¶
func NewJsonConfig() *JsonConfig
func (*JsonConfig) Get ¶
func (j *JsonConfig) Get(values ...Value) (interface{}, bool)
func (*JsonConfig) Read ¶
func (j *JsonConfig) Read(data []byte)
func (*JsonConfig) Unmarshal ¶
func (j *JsonConfig) Unmarshal(v interface{}) error