diff options
| author | stlpmo <hq-STLPMO@chinaunicom.cn> | 2019-11-11 10:52:21 +0800 |
|---|---|---|
| committer | stlpmo <hq-STLPMO@chinaunicom.cn> | 2019-11-11 10:52:21 +0800 |
| commit | 62d393d6c90362bd596bd841266ca9390fe3bb86 (patch) | |
| tree | 6623af543b2edd16b3bae412652a7cded774ef01 /weed/util/config.go | |
| parent | 802a0eb3fe115cd213d1238912fe431601e8f102 (diff) | |
| download | seaweedfs-62d393d6c90362bd596bd841266ca9390fe3bb86.tar.xz seaweedfs-62d393d6c90362bd596bd841266ca9390fe3bb86.zip | |
ut pass
Diffstat (limited to 'weed/util/config.go')
| -rw-r--r-- | weed/util/config.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/weed/util/config.go b/weed/util/config.go index f51955263..385ef92d7 100644 --- a/weed/util/config.go +++ b/weed/util/config.go @@ -1,6 +1,8 @@ package util import ( + "fmt" + "github.com/chrislusf/seaweedfs/weed/glog" "github.com/spf13/viper" ) @@ -46,9 +48,13 @@ func Config() Configuration { return viper.GetViper() } -func SubConfig(subKey string) Configuration { +func SubConfig(subKey string) (Configuration, error) { if subKey != "" { - return viper.GetViper().Sub(subKey) + sub := viper.GetViper().Sub(subKey) + if sub == nil { + return nil, fmt.Errorf("sub config [%s] not exist", subKey) + } + return sub, nil } - return viper.GetViper() + return viper.GetViper(), nil }
\ No newline at end of file |
