Documentation ¶
Index ¶
- Variables
- func OnFlagChange(flagName string, callback FlagChangeCallback)
- func Parse()
- func ReadIniFile(iniFilePath string) (args []flagArg, ok bool)
- func SetAllowMissingConfigFile(allowed bool)
- func SetAllowUnknownFlags(allowed bool)
- func SetConfigFile(path string)
- func SetConfigUpdateInterval(interval time.Duration)
- func SetLogger(l Logger)
- type FlagChangeCallback
- type Logger
Constants ¶
This section is empty.
Variables ¶
var Generation int
Generation is flags' generation number.
It is modified on each flags' modification via either -configUpdateInterval or SIGHUP.
Functions ¶
func OnFlagChange ¶
func OnFlagChange(flagName string, callback FlagChangeCallback)
OnFlagChange registers the callback, which is called after the given flag value is initialized and/or changed.
Flag values are initialized during iniflags.Parse() call. Flag value can be changed on config re-read after obtaining SIGHUP signal or if periodic config re-read is enabled with -configUpdateInterval flag.
Note that flags set via command-line cannot be overriden via config file modifications.
func Parse ¶
func Parse()
Parse obtains flag values from config file set via -config.
It obtains flag values from command line like flag.Parse(), then overrides them by values parsed from config file set via -config.
Path to config file can also be set via SetConfigFile() before Parse() call.
func ReadIniFile ¶
func SetAllowMissingConfigFile ¶
func SetAllowMissingConfigFile(allowed bool)
func SetAllowUnknownFlags ¶
func SetAllowUnknownFlags(allowed bool)
func SetConfigFile ¶
func SetConfigFile(path string)
SetConfigFile sets path to config file.
Call this function before Parse() if you need default path to config file when -config command-line flag is not set.
func SetConfigUpdateInterval ¶
Types ¶
type FlagChangeCallback ¶
type FlagChangeCallback func()
FlagChangeCallback is called when the given flag is changed.
The callback may be registered for any flag via OnFlagChange().
type Logger ¶
type Logger interface { Printf(format string, v ...interface{}) Fatalf(format string, v ...interface{}) Panicf(format string, v ...interface{}) }
Logger is a slimmed-down version of the log.Logger interface, which only includes the methods we use. This interface is accepted by SetLogger() to redirect log output to another destination.