KDOC 362: コンパイル可能な最低バージョンと、ビルドに使うバージョン
この文書のステータス
- 作成
- 2025-05-05 貴島
- レビュー
- 2025-05-05 貴島
概要
KDOC 360: goとtoolchainの違いは何か?を調べた。
go.modの仕様書go.mod file reference - The Go Programming Languageを見る。
↓go directive。
Indicates that the module was written assuming the semantics of the Go version specified by the directive.
The minimum version of Go required to compile packages in this module.
moduleが想定するセマンティクス、コンパイルできる最低バージョンを示す。
↓toolchain directive。
Declares a suggested Go toolchain to use with this module. Only takes effect when the module is the main module and the default toolchain is older than the suggested toolchain.
推奨するGo toolchainの名前を指定する。main moduleかつ、default(ローカルのGo)が指定バージョンより古いときだけ動作する。
goディレクティブは依存関係の解決に使われ、toolchainディレクティブはmain moduleとしてコンパイルするときに使われる、みたいなイメージだろうか。
だから、コンパイルするときに考慮されるときは以下のように考慮されて、ビルドに使うバージョンを決定するということだろうか。
- 使用ライブラリのgo.modのgoディレクティブ
- main moduleのgo.modのgoディレクティブ
- main moduleのgo.modのtoolchainディレクティブ