Go依赖管理工具
目前版本:
为v0.4.1
若$GOPATH/bin
不在PATH
下,则需要将生成的dep
文件从$GOPATH/bin
移动至$GOBIAN
下
验证
在项目根目录执行初始化命令,dep
在初始化时会分析应用程序所需要的所有依赖包,得出依赖包清单
并生成vendor
目录,Gopkg.toml
、Gopkg.lock
文件
$ dep init -v
直接从对应网络资源处下载
优先从$GOPATH初始化
该命令会先从$GOPATH
查找既有的依赖包,若不存在则从对应网络资源处下载
该文件由dep init
生成,包含管理dep
行为的规则声明
required = ["github.com/user/thing/cmd/thing"]
ignored = [
"bitbucket.org/user/project/pkgA/pkgY"
]
[metadata]
key1 = "value that convey data to other systems"
system1-data = "value that is used by a system"
system2-data = "value that is used by another system"
[[constraint]]
# Required: the root import path of the project being constrained.
name = "github.com/user/project"
# Note that only one of "branch", "version" or "revision" can be specified.
version = "1.0.0"
branch = "master"
revision = "abc123"
# Optional: an alternate location (URL or import path) for the project's source.
# Optional: metadata about the constraint or override that could be used by other independent systems
[metadata]
key1 = "value that convey data to other systems"
system1-data = "value that is used by a system"
system2-data = "value that is used by another system"
Gopkg.lock
该文件由dep ensure
和dep init
生成,包含一个项目依赖关系图的传递完整快照,表示为一系列[[project]]
节
常用命令
用于确保本地的关系图、锁、依赖包清单完全一致
dep ensure -add
# 引入该依赖包的最新版本
dep ensure -add github.com/pkg/foo
dep ensure -add github.com/pkg/foo@^1.0.1
将Gopkg.lock
中的约定依赖项更新为Gopkg.toml
允许的最新版本
目前还在官方试验阶段,但已表示生产可安全使用
如果出现什么问题,大家可以一起留个言讨论讨论