Description
Go 1.26 introduced a rewritten go fix subcommand with a source-level inliner. The //go:fix inline directive allows annotating deprecated functions, type aliases, and variables so that go fix (or IDEs) automatically rewrite call sites to the modern replacement.
For tektoncd/triggers this is relevant in two ways:
-
As a consumer: Once tektoncd/pipeline adds //go:fix inline annotations to its deprecated APIs, triggers can run go fix ./... to auto-migrate usage of deprecated pipeline types.
-
Own deprecated APIs: triggers has some deprecated code that could be annotated.
Prerequisite
Bump go.mod to Go 1.26 (currently at 1.24.0 — this is the furthest behind of the tektoncd projects).
Opportunities
Own Deprecated APIs
The generated informer factory has a deprecated wrapper:
// pkg/client/informers/externalversions/factory.go
// Deprecated: Please use NewSharedInformerFactoryWithOptions instead
//
//go:fix inline
func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory {
return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions))
}
Note: This is generated code, so the annotation would need to be added at the code generator level or post-generation.
Go 1.26 built-in modernizers
Beyond //go:fix inline, Go 1.26's go fix ships with 24+ built-in modernizers that can automatically apply improvements like:
- Using
slices.Sort instead of sort.Slice
- Using
min/max builtins
- Using
strings.Cut instead of strings.Index + slice
- And more
Running go fix ./... after bumping to Go 1.26 would apply all applicable modernizations.
References
Description
Go 1.26 introduced a rewritten
go fixsubcommand with a source-level inliner. The//go:fix inlinedirective allows annotating deprecated functions, type aliases, and variables so thatgo fix(or IDEs) automatically rewrite call sites to the modern replacement.For tektoncd/triggers this is relevant in two ways:
As a consumer: Once tektoncd/pipeline adds
//go:fix inlineannotations to its deprecated APIs, triggers can rungo fix ./...to auto-migrate usage of deprecated pipeline types.Own deprecated APIs: triggers has some deprecated code that could be annotated.
Prerequisite
Bump
go.modto Go 1.26 (currently at 1.24.0 — this is the furthest behind of the tektoncd projects).Opportunities
Own Deprecated APIs
The generated informer factory has a deprecated wrapper:
Note: This is generated code, so the annotation would need to be added at the code generator level or post-generation.
Go 1.26 built-in modernizers
Beyond
//go:fix inline, Go 1.26'sgo fixships with 24+ built-in modernizers that can automatically apply improvements like:slices.Sortinstead ofsort.Slicemin/maxbuiltinsstrings.Cutinstead ofstrings.Index+ sliceRunning
go fix ./...after bumping to Go 1.26 would apply all applicable modernizations.References