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

オープン
#3,280 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
42/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
go

調査の方向性

go.mod から始め、pkg/client/informers/externalversions/factory.go と pkg/apis/operator/v1alpha1/ 配下の非推奨 API 型を確認した後、go fix ./... を実行します。結果として生じた変更を issue #9560 のパイプライン前提条件と照合して確認し、その後リポジトリのテストを実行します。Go 1.26 への移行、該当するアノテーション、およびモダナイゼーションが確認・検証済みであれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Go
スター
606
フォーク
270
平均マージ
1日 7時間
マージ済み PR(30日)
159

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

tektoncd/operator のほかの issue

tektoncd/operator の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。