doc: notic check instance return by viper.Sub

This commit is contained in:
j2gg0s 2020-09-26 12:12:24 +08:00
parent a0285163e1
commit 8a91529b51

View file

@ -653,6 +653,9 @@ cfg2 := viper.Sub("app.cache2")
cache2 := NewCache(cfg2)
```
Notice `Sub` will return `nil` when key does not exist.
And you should check new viper instance return by `Sub` to avoid invalid memory address error.
### Unmarshaling
You also have the option of Unmarshaling all or a specific value to a struct, map,