MVS (Minimal VersionSelection) アルゴリズムの気持ち
画像引用: https://go.dev/ref/mod#minimal-version-selection
If a module appears in the list
multiple times, keep only the
newest version.
モジュールがリストに複数回現れる場
合、最新のバージョンのみを保持す
る。
引用:
https://research.swtch.com/vgo-mvs
8.
go tool (tools.go)の使用と依存関係 tree への影響
main モジュールはバージョン
1.1のモジュールBを使う。
しかしながら、tool A がバー
ジョン1.2のモジュール B を
使うために main モジュール
の build にはモジュール B
が使われる 。
→ ただし、この挙動は意図
されたもの。
main
B 1.1 B 1.2
tool A
「ただし、これは意図された動作である。」の根拠は?
The go commandis not going to start dealing with multiple build graphs in a single command - that
would be a very large amount of implementation complexity, far outweighing the entire benefit of
having tool lines at all.
goコマンドは、単一のコマンドで複数のビルドグラフを扱うことはしません。それは非常に大量の実装の複雑さを
伴い、ツール行を持つことの全体的な利益を大幅に上回ってしまうからです。
https://github.com/golang/go/issues/48429#issuecomment-1599344310
The definition of "all" influences many things. After talking to @bcmills and @matloob, I believe
(and I believe they agree) that modules providing tools and modules providing tool dependencies
need to be included in "all". The reason is that commands like "go mod graph", "go mod verify",
"go mod download", and "go mod vendor" are all keyed off of "all", as is the content of go.sum.
「all」の定義は多くのことに影響を与えます。 @bcmillsと@matloobと話し合った結果、私は(彼らも同意している
と思いますが)、ツールを提供するモジュールとツール依存関係を提供するモジュールは「 all」に含まれる必要が
あると考えています。その理由は、「 go mod graph」、「go mod verify」、「go mod download」、「go mod vendor」
などのコマンドはすべて「 all」をキーとしており、go.sumの内容も同様だからです。
https://github.com/golang/go/issues/48429#issuecomment-1652292960
16.
-modfile オプションを使った例を知りたい
go get-modfile=tools.mod
go tool -modfile=tools.mod go.uber.org/mock/mockgen -version
上記のようにして -modfile オプションを利用可能。