Go dep's dep ensure
command will remove packages not currently in use. There's one particular package we use for debugging github.com/sanity-io/litter. The challenge we're facing is if we run dep ensure
outside of a debugging session, dep
will remove that package.
One solution could be to call that package in some backstage spot in the code that won't bother anyone, thereby showing dep that we are, in fact, using this package. But that sounds ugly, hacky, and could get removed by a future developer on the team.
So, the question is, how to tell dep to keep a package, even if it's not currently in use?
Add to the beginning of Gopkg.toml
:
required = ["github.com/sanity-io/litter"]
The Gopkg.toml docs state about required
:
Use this for: linters, generators, and other development tools that
- Are needed by your project
- Aren't imported by your project, directly or transitively
- You don't want to put them in your
GOPATH
, and/or you want to lock the versionPlease note that this only pulls in the sources of these dependencies. It does not install or compile them.
You should use required
for your dependency, take a look at documentation about it. And maybe more useful link about required section.