Official docs:

The changes are applied in the go.mod file.

When using a Github repo or other similar, the version has to be informed:

replace github.com/author/repo v1.2.3 => github.com/otherauthor/repo master

It also works pointing locally (the version is not required):

replace github.com/author/repo v1.2.3 => /path/to/package