mirror of
https://github.com/spf13/viper
synced 2025-05-07 12:47:18 +00:00
Merge da44dc1a84
into 7a605a50e6
This commit is contained in:
commit
262e65acc0
1 changed files with 10 additions and 0 deletions
10
README.md
10
README.md
|
@ -103,6 +103,16 @@ if err != nil { // Handle errors reading the config file
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Alternatively (or in addition), the path to a specific config file can be provided (instead of a directory).
|
||||||
|
|
||||||
|
```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 while loading 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…
Add table
Reference in a new issue