-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: updating go mod edit -replace
d version is a nightmare
#45413
Comments
For questions please refer to https://github.com/golang/go/wiki/Questions |
This causes me grief every time I need to update my fancybits branch. I gather the idiom for pointing to a fork on a branch is:
(It is awkward that the first method for step 2 forbids the @, but the second method requires it.) Where is all this clearly documented? https://golang.org/ref/mod#go-mod-file-replace probably should, but doesn't. |
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: