Skip to content

Commit

Permalink
chore: use a switch statement for Config.Value()
Browse files Browse the repository at this point in the history
Co-authored-by: Alyx Holms <[email protected]>
  • Loading branch information
computator and superlinkx committed Dec 6, 2023
1 parent 0efc2dd commit 8a60edd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions config/internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ type Config struct {
}

func (s Config) Value() interface{} {
if defkind := reflect.ValueOf(s.Default).Kind(); defkind == reflect.Slice {
switch reflect.ValueOf(s.Default).Kind() {
case reflect.Slice:
return viper.GetStringSlice(s.Name)
} else if defkind == reflect.Int {
case reflect.Int:
return viper.GetInt(s.Name)
} else {
default:
return viper.Get(s.Name)
}
}
Expand Down

0 comments on commit 8a60edd

Please sign in to comment.