Use //go:fix inline and go fix to modernize codebase

Aperta
#3,280 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
go

Direzione di ricerca

Inizia da go.mod ed esegui go fix ./... dopo aver esaminato pkg/client/informers/externalversions/factory.go e i tipi API deprecati in pkg/apis/operator/v1alpha1/. Verifica le modifiche risultanti rispetto al prerequisito della pipeline nell’issue #9560, quindi esegui i test del repository. Il lavoro è completato quando la migrazione a Go 1.26, le annotazioni applicabili e le modernizzazioni sono state esaminate e convalidate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

kind/cleanup

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/operator this is relevant in two ways:

  1. As a consumer: Once tektoncd/pipeline adds //go:fix inline annotations to its deprecated APIs, operator can run go fix ./... to auto-migrate usage of deprecated pipeline types and functions.

  2. Own deprecated APIs: operator has deprecated fields and generated code that could be annotated.

Prerequisite

Bump go.mod to Go 1.26 (currently at 1.25.5).

Opportunities

Own Deprecated APIs

The generated informer factory has the common deprecated wrapper pattern:

// 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))
}

Deprecated fields in the operator API types (pkg/apis/operator/v1alpha1/) could also benefit from annotation where applicable.

Consuming pipeline's annotations

Once tektoncd/pipeline annotates its deprecated APIs (tektoncd/pipeline#9560), running go fix ./... in operator will automatically migrate:

  • Deprecated type aliases (e.g. ArrayOrString → ParamValue)
  • Deprecated wrapper functions
  • Deprecated resolution package imports
Go 1.26 built-in modernizers

Beyond //go:fix inline, Go 1.26's go fix ships with 24+ built-in modernizers that automatically apply improvements like using slices.Sort, min/max builtins, strings.Cut, and more. Running go fix ./... after bumping to Go 1.26 would apply all applicable modernizations.

References

Lingua principale
Go
Stelle
606
Fork
270
Merge medio
1g 7h
PR unite (30g)
159

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tektoncd/operator

Tutte le issue di tektoncd/operator

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.