Skip to content

Commit

Permalink
refactor: make unmarshal error handling clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
yasarluo authored Aug 21, 2020
1 parent 10b2f0b commit 07535a5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions env.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,10 @@ func getOr(key, defaultValue string, defExists bool, envs map[string]string) (va
func set(field reflect.Value, sf reflect.StructField, value string, funcMap map[reflect.Type]ParserFunc) error {
var tm = asTextUnmarshaler(field)
if tm != nil {
var err = tm.UnmarshalText([]byte(value))
return newParseError(sf, err)
if err := tm.UnmarshalText([]byte(value)); err != nil {
return newParseError(sf, err)
}
return nil
}

var typee = sf.Type
Expand Down

0 comments on commit 07535a5

Please sign in to comment.