chore: updates for go 1.24.1 (#3712)

Signed-off-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
Keith Zantow 2025-03-06 10:35:26 -05:00 committed by GitHub
parent e8c62faefc
commit 7571f8dfba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 14 additions and 14 deletions

View File

@ -26,7 +26,7 @@ tools:
# used for linting # used for linting
- name: golangci-lint - name: golangci-lint
version: version:
want: v1.64.5 want: v1.64.6
method: github-release method: github-release
with: with:
repo: golangci/golangci-lint repo: golangci/golangci-lint

View File

@ -21,7 +21,7 @@ jobs:
analyze: analyze:
name: Analyze name: Analyze
runs-on: ubuntu-22.04-4core-16gb runs-on: ubuntu-22.04-4core-16gb
if: github.repository == 'anchore/syft' # only run for main repo
permissions: permissions:
security-events: write security-events: write

View File

@ -15,6 +15,7 @@ jobs:
name: "Publish test fixture image cache" name: "Publish test fixture image cache"
# we use this runner to get enough storage space for docker images and fixture cache # we use this runner to get enough storage space for docker images and fixture cache
runs-on: ubuntu-22.04-4core-16gb runs-on: ubuntu-22.04-4core-16gb
if: github.repository == 'anchore/syft' # only run for main repo
permissions: permissions:
packages: write packages: write
steps: steps:

View File

@ -62,11 +62,6 @@ linters-settings:
excludes: excludes:
- G115 - G115
staticcheck:
checks:
- all
- -SA4023
run: run:
timeout: 10m timeout: 10m
tests: false tests: false

View File

@ -54,7 +54,7 @@ func lowerFirst(s string) string {
} }
// Encode recursively encodes the object's properties as an ordered set of NameValue pairs // Encode recursively encodes the object's properties as an ordered set of NameValue pairs
func Encode(obj interface{}, prefix string, fn FieldName) map[string]string { func Encode(obj any, prefix string, fn FieldName) map[string]string {
if obj == nil { if obj == nil {
return nil return nil
} }
@ -86,7 +86,7 @@ func Sorted(values map[string]string) (out []NameValue) {
} }
func encode(out map[string]string, value reflect.Value, prefix string, fn FieldName) { func encode(out map[string]string, value reflect.Value, prefix string, fn FieldName) {
if !value.IsValid() || value.Type() == nil { if !value.IsValid() {
return return
} }
@ -156,7 +156,7 @@ func fieldName(f reflect.StructField, prefix string, fn FieldName) (string, bool
} }
// Decode based on the given type, applies all values to hydrate a new instance // Decode based on the given type, applies all values to hydrate a new instance
func Decode(typ reflect.Type, values map[string]string, prefix string, fn FieldName) interface{} { func Decode(typ reflect.Type, values map[string]string, prefix string, fn FieldName) any {
isPtr := false isPtr := false
for typ.Kind() == reflect.Ptr { for typ.Kind() == reflect.Ptr {
typ = typ.Elem() typ = typ.Elem()
@ -185,7 +185,7 @@ func Decode(typ reflect.Type, values map[string]string, prefix string, fn FieldN
} }
// DecodeInto decodes all values to hydrate the given object instance // DecodeInto decodes all values to hydrate the given object instance
func DecodeInto(obj interface{}, values map[string]string, prefix string, fn FieldName) { func DecodeInto(obj any, values map[string]string, prefix string, fn FieldName) {
value := reflect.ValueOf(obj) value := reflect.ValueOf(obj)
for value.Type().Kind() == reflect.Ptr { for value.Type().Kind() == reflect.Ptr {
@ -197,7 +197,7 @@ func DecodeInto(obj interface{}, values map[string]string, prefix string, fn Fie
//nolint:funlen,gocognit,gocyclo //nolint:funlen,gocognit,gocyclo
func decode(vals map[string]string, value reflect.Value, prefix string, fn FieldName) bool { func decode(vals map[string]string, value reflect.Value, prefix string, fn FieldName) bool {
if !value.IsValid() || value.Type() == nil { if !value.IsValid() {
return false return false
} }
@ -361,7 +361,7 @@ func decode(vals map[string]string, value reflect.Value, prefix string, fn Field
return true return true
} }
func PtrToStruct(ptr interface{}) interface{} { func PtrToStruct(ptr any) any {
v := reflect.ValueOf(ptr) v := reflect.ValueOf(ptr)
if v.IsZero() && v.Type().Kind() != reflect.Struct { if v.IsZero() && v.Type().Kind() != reflect.Struct {
return nil return nil
@ -371,6 +371,10 @@ func PtrToStruct(ptr interface{}) interface{} {
return PtrToStruct(v.Elem().Interface()) return PtrToStruct(v.Elem().Interface())
case reflect.Interface: case reflect.Interface:
return PtrToStruct(v.Elem().Interface()) return PtrToStruct(v.Elem().Interface())
default:
if v.CanInterface() {
return v.Interface()
}
} }
return v.Interface() return nil
} }