Go dep keep package 即使当前没有使用
Go dep keep package even if not currently used
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。我们面临的挑战是,如果我们 运行 dep ensure
在调试会话之外,dep
将删除该包。
一个解决方案可能是在不会打扰任何人的代码中的某个后台位置调用该包,从而向 dep 表明我们实际上正在使用该包。但这听起来很丑陋,而且可能会被团队中未来的开发人员删除。
所以,问题是,如何告诉 dep 保留一个包,即使它当前没有被使用?
你应该使用 required
作为你的依赖,看看 documentation
关于它。 link 关于 required 部分可能更有用。
添加到Gopkg.toml
的开头:
required = ["github.com/sanity-io/litter"]
The Gopkg.toml docs 状态关于 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 version
Please note that this only pulls in the sources of these dependencies.
It does not install or compile them.
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。我们面临的挑战是,如果我们 运行 dep ensure
在调试会话之外,dep
将删除该包。
一个解决方案可能是在不会打扰任何人的代码中的某个后台位置调用该包,从而向 dep 表明我们实际上正在使用该包。但这听起来很丑陋,而且可能会被团队中未来的开发人员删除。
所以,问题是,如何告诉 dep 保留一个包,即使它当前没有被使用?
你应该使用 required
作为你的依赖,看看 documentation
关于它。 link 关于 required 部分可能更有用。
添加到Gopkg.toml
的开头:
required = ["github.com/sanity-io/litter"]
The Gopkg.toml docs 状态关于 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.