From 8a91529b51f173c3cc9989c3d1e8440f57840bf0 Mon Sep 17 00:00:00 2001 From: j2gg0s Date: Sat, 26 Sep 2020 12:12:24 +0800 Subject: [PATCH] doc: notic check instance return by viper.Sub --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index dfd8034..4ed0e09 100644 --- a/README.md +++ b/README.md @@ -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,