[英]Go dep keep package even if not currently used
Go dep 's dep ensure
command will remove packages not currently in use. Go dep的
dep ensure
命令将删除当前未使用的软件包。 There's one particular package we use for debugging github.com/sanity-io/litter . 有一个用于调试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. 我们面临的挑战是,如果我们在调试会话之外运行
dep ensure
,则dep
将删除该软件包。
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. 一种解决方案是在代码的某个后台位置调用该程序包,该程序包不会困扰任何人,从而表明dep实际上我们正在使用此程序包。 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? 因此,问题是,即使当前不使用它,如何告诉dep保留一个包装?
You should use required
for your dependency, take a look at documentation about it. 您应该使用
required
作为依赖项,并查看有关它的文档 。 And maybe more useful link about required section. 也许有关所需部分的更有用的链接。
Add to the beginning of Gopkg.toml
: 添加到
Gopkg.toml
的开头:
required = ["github.com/sanity-io/litter"]
The Gopkg.toml docs state about required
: Gopkg.toml文档说明了
required
:
Use this for: linters, generators, and other development tools that
将此用于以下各项:linter,生成器和其他开发工具
- 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您不想将它们放在
GOPATH
,并且/或者您想要锁定版本Please note that this only pulls in the sources of these dependencies.
请注意,这仅会提取这些依赖项的来源。 It does not install or compile them.
它不会安装或编译它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.