Skip to content

Commit 1a51998

Browse files
committed
change signature of the hook
1 parent 8ad1a69 commit 1a51998

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

pkg/config/config.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"strings"
66
"time"
77

8-
"github.com/mitchellh/mapstructure"
98
"github.com/pkg/errors"
109
"github.com/rs/zerolog"
1110
"github.com/rs/zerolog/log"
@@ -96,8 +95,7 @@ func New() (ServerConfig, error) {
9695

9796
func NewWithViper(v *viper.Viper) (ServerConfig, error) {
9897
var cfg ServerConfig
99-
if err := v.Unmarshal(&cfg, func(config *mapstructure.DecoderConfig) {
100-
config.DecodeHook = func(in reflect.Type, out reflect.Type, value interface{}) (interface{}, error) {
98+
if err := v.Unmarshal(&cfg, viper.DecodeHook( func(in reflect.Type, out reflect.Type, value interface{}) (interface{}, error) {
10199
if in.String() == "string" && out.String() == "zerolog.Level" {
102100
input := value.(string)
103101
return zerolog.ParseLevel(input)
@@ -120,8 +118,7 @@ func NewWithViper(v *viper.Viper) (ServerConfig, error) {
120118
}
121119

122120
return value, nil
123-
}
124-
}); err != nil {
121+
})); err != nil {
125122
return cfg, errors.Wrap(err, "failed to read configuration")
126123
}
127124

0 commit comments

Comments
 (0)