If I run a command similar to the following:
go build -mod=mod -o xyz.exe github.com/some/go/tool
And I'm in a directory with a go.mod, I noticed that the go.mod will be updated with a reference to github.com/some/go/tool
, and xyz.exe will be built. So the go.mod being used is the one in the current directory.
However, if I change to some empty tmp folder with no go.mod, the build still succeeds and no go.mod is generated or updated.
My question is: in the latter case, what go.mod is used? Does go use the one from github.com/some/go/tool? And, is this documented somewhere?