Skip to content

Ran go fix on this codebase#189

Open
thomasvn wants to merge 3 commits into
developfrom
thomasn/go-fix
Open

Ran go fix on this codebase#189
thomasvn wants to merge 3 commits into
developfrom
thomasn/go-fix

Conversation

@thomasvn

Copy link
Copy Markdown
Member

Apply go fix modernizations (Go 1.26)

Ran go fix ./... to apply automated source-level rewrites suggested by the Go 1.26 toolchain. No logic changes; all fixes are mechanical and semantically equivalent to the code they replace.

go fix ./...
go build ./...   # verified clean

Changes by analyzer

Analyzer Rule Files
any interface{}any cldy/clients.go, pkg/cluster/dynamic.go, pkg/env/unifiedagentenv.go
reflecttypefor reflect.TypeOf(T{})reflect.TypeFor[T]() pkg/cluster/dynamic.go
rangeint index-only for loops → for range N pkg/cluster/dynamic.go, pkg/nodes/request.go, kubecost/adapters/metricsquerier_test.go
newexpr aws.String(x) / aws.Int(n)new(x) / new(n) cldy/clients.go

any — idiomatic alias for interface{}

any has been the preferred alias since Go 1.18.

reflect.TypeFor[T]() — type-safe, allocation-free

reflect.TypeOf(T{}) allocates a zero-value struct to extract its type. reflect.TypeFor[T]() (Go 1.22) resolves the type at compile time and works correctly for interface types, where the old idiom required the cumbersome reflect.TypeOf((*T)(nil)).Elem().

for range N — cleaner iteration

for i := 0; i < n; i++for i := range n. Where the index variable is unused entirely, the loop becomes for range n.

new(expr) — replaces pointer-helper functions

Go 1.26 extended new to accept an expression: new(expr) allocates a copy of expr and returns its address. This replaces the aws.String / aws.Int helper-function pattern that was necessary before this language change.

// before
Region:     aws.String(s3Region),
MaxRetries: aws.Int(3),

// after
Region:     new(s3Region),
MaxRetries: new(3),

@thomasvn thomasvn marked this pull request as ready for review June 20, 2026 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant