My package github.com/me/foo
is a module with a go.mod. It contains a require
directive for github.com/thirdparty/bar
, which imports github.com/thirdparty/baz
(through an import
in a .go file). However, bar
is not a module, and doesn’t specify where to find baz
.
How is baz
resolved?
Would it use foo/go.mod
? Would it use bar/go.mod
, if it had one? Or does it only search GOPATH/GOROOT? I know foo
has already downloaded baz
to $GOPATH/pkg/mod
. Does Go “know” it’s running from foo
, and use foo
's go.mod to resolve all import paths anywhere in its tree? What if a dependency wants to use its own version?