Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creates the Env reader
`mapFlagKey` is a map of the names of the flag and the configuration keys `prefix` is a default prefix that will be added to all configuration keys
Example ¶
package main import ( "context" "fmt" flag "github.com/spf13/pflag" "github.com/sv-tools/conf" confflags "github.com/sv-tools/conf-reader-flags" ) func main() { flag.IntP("foo", "f", 1, "testing flag") if err := flag.CommandLine.Parse([]string{"--foo=42"}); err != nil { panic(err) } c := conf.New().WithReaders(confflags.New(map[string]string{"foo": "foo"}, "", nil)) if err := c.Load(context.Background()); err != nil { panic(err) } fmt.Println(c.GetInt("foo")) }
Output: 42
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.