Module resolution for dependencies of dependencies?

My package is a module with a go.mod. It contains a require directive for, which imports (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?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.