v0.1.0 Release
This commit is contained in:
21
doc/env.md
21
doc/env.md
@ -99,6 +99,19 @@ cfg.RegisterWithEnv("server.port", 8080, "PORT")
|
||||
cfg.RegisterWithEnv("database.url", "localhost", "DATABASE_URL")
|
||||
```
|
||||
|
||||
## Using the `env` Tag
|
||||
|
||||
Structs can specify explicit environment variable names using the `env` tag:
|
||||
|
||||
```go
|
||||
type Config struct {
|
||||
Server struct {
|
||||
Port int `toml:"port" env:"PORT"` // Uses $PORT
|
||||
Host string `toml:"host" env:"SERVER_HOST"` // Uses $SERVER_HOST
|
||||
} `toml:"server"`
|
||||
}
|
||||
```
|
||||
|
||||
## Environment Variable Whitelist
|
||||
|
||||
Limit which paths can be set via environment:
|
||||
@ -186,10 +199,4 @@ cfg, _ := config.NewBuilder().
|
||||
config.SourceDefault,
|
||||
).
|
||||
Build()
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
- [Command Line](cli.md) - CLI argument handling
|
||||
- [File Configuration](file.md) - Configuration file formats
|
||||
- [Access Patterns](access.md) - Retrieving values
|
||||
```
|
||||
Reference in New Issue
Block a user