Documentation ¶
Overview ¶
This file provides the Config type which can be used to populate a struct with options specified on the command line or by environment variables. Usage:
type MyConfig struct { StateFile string `desc:"File in which to store lock state" default:"" short:"s"` DefaultLockTimeout time.Duration `desc:"Lock timeout to use when loading locks from state file on startup" default:"10m" short:"d"` NoClearOnDisconnect bool `desc:"Do not clear locks on client disconnect" default:"false" short:"c"` FooSeconds uint32 `desc:"Something" default:"10" short:"f"` FooInt int `desc:"Something" default:"100" short:"o"` } conf := Configure[MyConfig](&Options{ EnvPrefix: "MYAPP_", Args: os.Args[1:], }) // `conf` fields are now populated with their defaults or values specified in // os.Args or environment variables. Not all golang types have been implemented - // only ones needed for ldlm.
cli argument names are converted to snake case. E.g. StateFile becomes --state_file.
environment variables must be prefixed with the envPrefix specified in Configure() and are converted to upper case snake. E.g. StateFile with an envPrefix of "MYAPP_" would be set with `MYAPP_STATE_FILE=/data/locks.state`.
Field tags:
- desc - The description of the configuration option
- default - The default value of the configuration option if none is specified
- short (optional) - The short flag version of the cli option.
This file contains handlers for reflect types handled in configuration parsing
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.