The module in ./hello has a mod file with a module path in it.
Whenever the main module (that is, the module where you invoke the Go commands) has a go.work file, then every import path that matches the module path in ./hello/go.mod will be redirected to the local module.
Example:
go.work in the main module:
use ./hello
.hello/go.mod:
module git.hoster/my/repository
main.go:
import "git.hoster/my/repository"
Here, the import path matches the module path of the local module in ./hello, and the Go commands will use this local module instead of the remote one.
(Disclaimer: Written at 10:30pm on a mobile - all errors are mine.)
If there’s go.work, the import example.com/module will try those local directories in go.work first. If not found, it will try online repositories. And module names like this example.com/module, github.com/golang/glog, etc. are unique, so there will be no ambiguous. Am I thinking right?