Skip to content

Ran go fix on this codebase - #189

Merged
thomasvn merged 6 commits into
developfrom
thomasn/go-fix
Aug 7, 2026
Merged

Ran go fix on this codebase#189
thomasvn merged 6 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

@mbolt35 mbolt35 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the syntax adjustments made by go fix - want to merge in the latest and re-run?

@thomasvn

thomasvn commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

@mbolt35 Thanks for review! I've merged in the latest and reran go fix ./...

@thomasvn
thomasvn requested a review from mbolt35 August 5, 2026 17:26

@mbolt35 mbolt35 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thomasvn
thomasvn added this pull request to the merge queue Aug 7, 2026
Merged via the queue into develop with commit 58628ea Aug 7, 2026
10 of 13 checks passed
@thomasvn
thomasvn deleted the thomasn/go-fix branch August 7, 2026 16:02
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.

2 participants