cmd/go: updating go mod edit -replace
d version is a nightmare
#45413
Labels
go mod edit -replace
d version is a nightmare
#45413
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Often I am using an open-source project, until I reach a point where I need to fork it.
Say for example I am using github.com/gin-gonic/gin very simply:
Now I need to make a change, so I fork a copy over to github.com/fancybits/gin and create a new branch
fancybits
. Next I usego mod edit -replace
to swap over to my fork:This is great and works as expected.
Next I start making changes to my fork. I make a new commit on the
fancybits
branch and push it up to github.Now I just want to update my go.mod to the new commit I just pushed, but I cannot figure out how. If I use
go get -u
, it yells at me:If I try
go mod edit -replace
again with the branch name, runninggo mod tidy
again just uses the old cached resolution of that branch to the old commit.If I try to use the actual commit sha instead of the branch name, it fetches the new commit information but then still fails and yells at me:
At this point I hoped maybe since it downloaded the new commit above, it would now have updated the cache. So I tried to run
go mod edit -replace github.com/gin-gonic/gin=github.com/fancybits/gin@fancybits && go mod tidy
but it didn't update my go.mod file.I also tried
go mod edit -dropreplace
and then adding the module back with-replace
but the old commit information is still cached somewhere.The only way I could make it work was to edit the go.mod file manually and replace the version information using what's printed in the error message from
go get -u github.com/fancybits/gin@fancybits
.Please make this easier.
The text was updated successfully, but these errors were encountered: