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 <aholms@specterops.io>
  • Loading branch information
computator and superlinkx authored Dec 6, 2023
1 parent 0efc2dd commit 93d2ab1
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)

Check failure on line 46 in config/internal/config.go

View workflow job for this annotation

GitHub Actions / test

syntax error: unexpected return, expected expression

Check failure on line 46 in config/internal/config.go

View workflow job for this annotation

GitHub Actions / build (darwin, amd64)

syntax error: unexpected return, expected expression

Check failure on line 46 in config/internal/config.go

View workflow job for this annotation

GitHub Actions / build (darwin, arm64)

syntax error: unexpected return, expected expression

Check failure on line 46 in config/internal/config.go

View workflow job for this annotation

GitHub Actions / build (linux, amd64)

syntax error: unexpected return, expected expression

Check failure on line 46 in config/internal/config.go

View workflow job for this annotation

GitHub Actions / build (linux, arm64)

syntax error: unexpected return, expected expression

Check failure on line 46 in config/internal/config.go

View workflow job for this annotation

GitHub Actions / build (windows, amd64)

syntax error: unexpected return, expected expression

Check failure on line 46 in config/internal/config.go

View workflow job for this annotation

GitHub Actions / build (windows, arm64)

syntax error: unexpected return, expected expression
} else {
default:
return viper.Get(s.Name)
}
}
Expand Down

0 comments on commit 93d2ab1

Please sign in to comment.