Description
Currently you must add a version when entering a non-filesystem (remote) replacement for a module. A foolish attempt to put replace github.com/fsnotify/fsnotify => gitmirror.corp.xyz.com/fsnotify/fsnotify
provokes a rebuke from go mod verify
:
go.mod:42: replacement module without version must be directory path (rooted or starting with ./ or ../)
- so you have to fix it to be:
replace github.com/fsnotify/fsnotify => gitmirror.corp.xyz.com/fsnotify/fsnotify v1.4.7
.
However, there is already a version specification for that package in go.mod
the require
statement, for example:
require github.com/fsnotify/fsnotify v1.4.7
This seems to be the reasonable default value for the missing version in the replace
directive for the same package - "if no replacement version is given, use the same as in the require
directive for that specific package`.
What would be especially nice is when upgrading a package such as github.com/fsnotify/fsnotify to the future v1..4.8 version, one would not need to first run go get -u github.com/fsnotify/fsnotify
and then have to look up the new version and manually update the old version to the new one in the replace
section (or worse, forgetting to do it and ending up with the unintended replacement with the old version).
@thepudds said on Slack that he wanted to suggest this as well. @bcmills @rsc - does it seem reasonable to you?