go.modとは?
go.modの解説。何をするもので、CI/CDでどう重要かを含みます。
go.modはGoモジュールを定義するファイルで、そのpath、Goのバージョン、依存関係の要件を記述します。
何であるか
必要なモジュールとその最小バージョンを列挙します。付随するgo.sumは整合性のための暗号学的チェックサムを記録します。
CI/CDで重要な理由
CIはgo build/go testを実行し、これらはgo.modを読んでgo.sumと照合します。-mod=readonly(CIのデフォルト)を使うと、go.modを黙って書き換える代わりにビルドが失敗します。
重要なポイント
- go.modはGoモジュールとその依存関係を定義します。
- go.sumはチェックサムをロックします。
- CIは整合性のために両方を検証します。
関連ガイド
What Is go.sum?go.sum records checksums for Go dependencies. Learn its security role in CI.
What Are Go Modules? Go Dependency Management ExplainedGo modules explained: how Go manages dependencies with go.mod and go.sum, a usage example, their role in CI/C…
What Is a Lockfile and Why Should You Commit It?A lockfile pins the exact versions of every dependency so builds are reproducible. Learn why committing it is…