Tuesday, February 06, 2018

Intent and execution in Go's dep tool

I'm starting to understand how the golang dep tool works, especially in terms of adding constraints to a dependency.

Taking the sample case from https://engineering.pivotal.io/post/go-dep-intro/, if we wanted to specify that we were using the dep-changes branch of github.com/fatih/color, we have two choices:

  • manually add a line with branch = "dep-changes" to the entry in Gopkg.toml, followed by a dep ensure to update Gopkg.lock and the vendor directory.
  • assuming we weren't already using the package when we did dep init or our most recent dep ensure, then on the command line enter dep ensure -add github.com/fatih/color@dep-changes, ensuring we add the code reference before we execute our next dep ensure.

No comments: