Skip to content

Commit

Permalink
fixup! feat(config): Allow avoiding reading default config file
Browse files Browse the repository at this point in the history
  • Loading branch information
hairyhenderson committed Sep 28, 2024
1 parent 0054e25 commit eecbf19
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ linters:
enable:
- asciicheck
- bodyclose
- copyloopvar
# - dogsled
# - dupl
- errcheck
# - exhaustive
- exportloopref
# - funlen
# - gci
# - gochecknoglobals
Expand Down
10 changes: 6 additions & 4 deletions conv/conv.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,15 @@ func ToInt64(v interface{}) (int64, error) {
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
return val.Int(), nil
case reflect.Uint8, reflect.Uint16, reflect.Uint32:
//nolint:gosec // G115 is not applicable, we can safely convert these
return int64(val.Uint()), nil
case reflect.Uint, reflect.Uint64:
tv := val.Uint()
if !val.CanUint() {
return -1, fmt.Errorf("could not convert %v to int64", v)
}

// this can overflow and give -1, but IMO this is better than
// returning maxint64
return int64(tv), nil
//nolint:gosec // G115 is not applicable, we already checked
return int64(val.Uint()), nil
case reflect.Float32, reflect.Float64:
return int64(val.Float()), nil
case reflect.Bool:
Expand Down
2 changes: 1 addition & 1 deletion conv/evalargs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func printableValue(v reflect.Value) (interface{}, bool) {
}

if !v.Type().Implements(errorType) && !v.Type().Implements(fmtStringerType) {
if v.CanAddr() && (reflect.PtrTo(v.Type()).Implements(errorType) || reflect.PtrTo(v.Type()).Implements(fmtStringerType)) {
if v.CanAddr() && (reflect.PointerTo(v.Type()).Implements(errorType) || reflect.PointerTo(v.Type()).Implements(fmtStringerType)) {
v = v.Addr()
} else {
switch v.Kind() {
Expand Down

0 comments on commit eecbf19

Please sign in to comment.