Upgrade to Pro — share decks privately, control downloads, hide ads and more …

go directiveを最新にしすぎないで欲しい話──あるいは、Go 1.26からgo mo...

Avatar for Arthur Arthur
February 25, 2026

go directiveを最新にしすぎないで欲しい話──あるいは、Go 1.26からgo mod initで作られるgo directiveの値が変わる話 / Go 1.26 リリースパーティ

Avatar for Arthur

Arthur

February 25, 2026
Tweet

More Decks by Arthur

Other Decks in Programming

Transcript

  1. go directive > The go directive sets the minimum version

    of Go required to use this module. https://go.dev/ref/mod#go-mod-file-go ビルドできる最小の言語バージョンを定義する 17
  2. Goのリリースポリシー > Each major Go release is supported until there

    are two newer major releases. https://go.dev/doc/devel/release#policy サポート対象のメジャーリリースは2つ分 【例】現在なら1.25と1.26がサポート下 18
  3. GoのProposalにも書かれている 「Proposal: all, x/build/cmd/relui: automate go directive maintenance in golang.org/x

    repositories」より引用: > Another option would be to always use the latest 1.(N-1).X, updating all the x repos each time a new minor Go release comes out. That forces everyone to update to that new minor release in order to incorporate any new x repo changes, which seems too aggressive. https://go.googlesource.com/proposal/+/HEAD/design/69095-x-repo-co ntinuous-go.md#why-not-bump-on-each-minor-release 27
  4. Go 1.26 Release Notesより > go mod init now defaults

    to a lower go version in new go.mod files. Running go mod init using a toolchain of version 1.N.X will create a go.mod file specifying the Go version go 1.(N-1).0. https://go.dev/doc/go1.26#go-command 40
  5. Go 1.26以降の挙動 手元のGoのバージョンより1つ前のメジャーリリースの バージョン※である1.(N-1).0が設定される: 43 $ GOTOOLCHAIN=go1.26.0 go mod init

    demo go: creating new go.mod: module demo $ grep go ./go.mod go 1.25.0 ※あくまでgo mod initを実行しているツールチェーンのバージョン基準。現時点でサポー トされているバージョンを取りに行くとネットワーク接続が必要になってしまうから
  6. なぜ変わったのか? Goがサポートしているバージョンと互換性のあるモ ジュールの作成を奨励するため > This is intended to encourage the

    creation of modules that are compatible with currently supported versions of Go. https://go.dev/doc/go1.26#go-command 44
  7. 議論が足りなかった? go mod initのgo directiveの値を変更するIssue https://github.com/golang/go/issues/74748 におい て、「We will do

    this for Go 1.26.」とされるまでの スレッド投稿数は計7件 一方、これを元に戻したいとするIssue https://github.com/golang/go/issues/77653 のス レッド投稿数は(本資料執筆時点で)計38件 46
  8. In my opinion…… Goチームが「サポートされているメジャーリリースと互換性のあ るモジュールにしたほうがいい」という指針を表明してくれたこ とは嬉しい go directiveが新しすぎて依存に困るケースが減ったらいいな 一方で、go mod

    initで生成されるgo directiveの値を変えるべき だったかどうかはなんとも言えない initしたあとgo directiveを変えてもいいので、レールとしては 中途半端。得られるメリットと比較して影響がでかそう 47