Ran go fix on this codebase#189
Open
thomasvn wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Apply
go fixmodernizations (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.Changes by analyzer
anyinterface{}→anycldy/clients.go,pkg/cluster/dynamic.go,pkg/env/unifiedagentenv.goreflecttypeforreflect.TypeOf(T{})→reflect.TypeFor[T]()pkg/cluster/dynamic.gorangeintforloops →for range Npkg/cluster/dynamic.go,pkg/nodes/request.go,kubecost/adapters/metricsquerier_test.gonewexpraws.String(x)/aws.Int(n)→new(x)/new(n)cldy/clients.goany— idiomatic alias forinterface{}anyhas been the preferred alias since Go 1.18.reflect.TypeFor[T]()— type-safe, allocation-freereflect.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 cumbersomereflect.TypeOf((*T)(nil)).Elem().for range N— cleaner iterationfor i := 0; i < n; i++→for i := range n. Where the index variable is unused entirely, the loop becomesfor range n.new(expr)— replaces pointer-helper functionsGo 1.26 extended
newto accept an expression:new(expr)allocates a copy ofexprand returns its address. This replaces theaws.String/aws.Inthelper-function pattern that was necessary before this language change.