Here's the scenario:
- in package
myPackageI make a breaking change. No worries, it's private, nobody cares - in project
myProjectI would like to use the newmyPackageversion. - running
go get -u ./...inmyProjectwill not update the package, since go will find errors (due to the breaking changes).
I can see how this is a good idea, but in this very case I would like go to force the update, break everything, so I can follow the compiler errors until my code is finally ready.
Is there any way to achieve this ?
CodePudding user response:
You can make use of the go mod edit directive to force pull a particular version of a package as a required dependency. In your case, assuming the changes are in "master" branch of your package, you could just do
go mod edit -require=<path>/<package>@latest
go mod vendor
The edit command modifies your go.mod, pointing the dependency to be pulled from the master branch. You could also specify branches ( @feature_branch ) or tags ( @v1.12 ) and then vendor pulls the actual contents.
