If you want to say, point to the local version of a dependency in Go rather than the one over the web, use the replace keyword.
The replace line goes above your require statements, like so:
module github.com/pselle/foo replace github.com/pselle/bar => /Users/pselle/Projects/bar require ( github.com/pselle/bar v1.0.0 )
And now when you compile this module (go install), it will use your local code rather than the other dependency.
According to the docs, you do need to make sure that the code you’re pointing to also has a go.mod file:
Note: if the right-hand side of ahttps://github.com/golang/go/wiki/Modules#when-should-i-use-the-replace-directive
replacedirective is a filesystem path, then the target must have a
go.modfile at that location. If the
go.modfile is not present, you can create one with
go mod init.
You can also create this line from the command line using the go mod edit
$ go mod edit -replace github.com/pselle/bar=/Users/pselle/Projects/bar
Following the -replace is first what you want to replace, then an equals sign, then what you’re replacing it with.
Hopefully this helps someone else get a quick answer to “how do I do this” in the future 🙂