dep version dep: version : devel build date : git hash : go version : go1.10.1 go compiler : gc platform : windows/amd64 features : ImportDuringSolve=false
dep ensure -add github.com/foo/bar github.com/baz/quux
移除依赖
通过执行命令
1
dep ensure
在输出中会提示代码中未使用的依赖(此时Gopkg.lock文件中已移除相应项)
1 2 3 4 5 6 7 8 9 10
Warning: the following project(s) have [[constraint]] stanzas in Gopkg.toml:
✗ github.com/sirupsen/logrus
However, these projects are not direct dependencies of the current project: they are not imported in any .go files, nor are they in the 'required' list in Gopkg.toml. Dep only applies [[constraint]] rules to direct dependencies, so these rules will have no effect.
...
然后手动从Gopkg.toml文件中移除列出的包即可
1 2 3 4 5 6 7 8 9 10 11
[[constraint]] name = "github.com/go-sql-driver/mysql" version = "1.3.0"
[[constraint]] name = "github.com/sirupsen/logrus" version = "1.0.5"
[[constraint]] name = "github.com/nsqio/go-nsq" version = "1.0.7"