Home > Blockchain >  is there a way to update go packages and ignore errors?
is there a way to update go packages and ignore errors?

Time:09-22

Here's the scenario:

  • in package myPackage I make a breaking change. No worries, it's private, nobody cares
  • in project myProject I would like to use the new myPackage version.
  • running go get -u ./... in myProject will 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.

  •  Tags:  
  • go
  • Related