mirror of
https://github.com/spf13/viper
synced 2024-12-23 12:07:02 +00:00
Document reading a specific config file in README
This commit is contained in:
parent
1a0c4a370c
commit
2cf56962a6
1 changed files with 11 additions and 0 deletions
11
README.md
11
README.md
|
@ -103,6 +103,17 @@ if err != nil { // Handle errors reading the config file
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Alternatively (or in addition), the path to a specific config file,
|
||||||
|
rather than to a directory containing config files, can be provided.
|
||||||
|
|
||||||
|
```go
|
||||||
|
viper.SetConfigFile("$HOME/customconfig.toml") // explicitly add a specific config file
|
||||||
|
err := viper.ReadInConfig() // read the config file
|
||||||
|
if err != nil { // Handle errors reading the config file
|
||||||
|
panic(fmt.Errorf("Fatal error config file: %s \n", err))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Watching and re-reading config files
|
### Watching and re-reading config files
|
||||||
|
|
||||||
Viper supports the ability to have your application live read a config file while running.
|
Viper supports the ability to have your application live read a config file while running.
|
||||||
|
|
Loading…
Reference in a new issue