Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creates the Env reader
`mapEnvKey` is a map of the names of the environment variables and the configuration keys `prefix` is a default prefix that will be added to all configuration keys
Example ¶
package main import ( "context" "fmt" "os" "github.com/sv-tools/conf" confenv "github.com/sv-tools/conf-reader-env" ) const envName = "TEST_FOO" func main() { if err := os.Setenv(envName, "42"); err != nil { panic(err) } c := conf.New().WithReaders(confenv.New(map[string]string{envName: "foo"}, "")) if err := c.Load(context.Background()); err != nil { panic(err) } fmt.Println(c.GetInt("foo")) if err := os.Unsetenv(envName); err != nil { panic(err) } }
Output: 42
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.