Package Usage: go: github.com/ardanlabs/conf/v3
Package conf provides support for using environmental variables and command
line arguments for configuration.
It is compatible with the GNU extensions to the POSIX recommendations
for command-line options. See
http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html
There are no hard bindings for this package. This package takes a struct
value and parses it for both the environment and flags. It supports several tags
to customize the flag options.
The field name and any parent struct name will be used for the long form of
the command name unless the name is overridden.
As an example, using this config struct:
The following usage information would be output you can display.
Usage: conf.test [options] [arguments]
OPTIONS
There is an API called Parse that can process a config struct with environment
variable and command line flag overrides.
There is also YAML support using the yaml package that is part of
this module.
There is a WithParse function that takes a slice of bytes containing the YAML
or WithParseReader that takes any concrete value that knows how to Read.
Additionally, if the config struct has a field of the slice type conf.Args
then it will be populated with any remaining arguments from the command line
after flags have been processed.
For example a program with a config struct like this:
If that program is executed from the command line like this:
Then the cfg.Args field will contain the string values ["serve", "http"].
The Args type has a method Num for convenient access to these arguments
such as this:
You can add a version with a description by adding the Version type to
your config type and set these values at run time for display.
9 versions
Latest release: over 1 year ago
70 dependent packages
View more package details: https://packages.ecosystem.code.gouv.fr/registries/proxy.golang.org/packages/github.com/ardanlabs/conf/v3