Go依赖管理工具 - dep
发布时间:2020-12-14 04:33:18 所属栏目:百科 来源:网络整理
导读:Go依赖管理工具 Go dependency management tool 环境要求 Golang = 1.9 Dep 目前版本: dep: version : devel build date : git hash : go version : go1.10 go compiler : gc platform : linux/amd64 Latest release 为 v0.4.1 安装 go get -u github.com/g
Go依赖管理工具Go dependency management tool 环境要求
目前版本:dep: version : devel build date : git hash : go version : go1.10 go compiler : gc platform : linux/amd64
安装go get -u github.com/golang/dep/cmd/dep 若 验证$ dep Dep is a tool for managing dependencies for Go projects Usage: "dep [command]" Commands: init Set up a new Go project,or migrate an existing one status Report the status of the project's dependencies ensure Ensure a dependency is safely vendored in the project prune Pruning is now performed automatically by dep ensure. version Show the dep version information Examples: dep init set up a new project dep ensure install the project's dependencies dep ensure -update update the locked versions of all dependencies dep ensure -add github.com/pkg/errors add a dependency to the project Use "dep help [command]" for more information about a command. 初始化在项目根目录执行初始化命令, 并生成
默认初始化$ dep init -v 直接从对应网络资源处下载 优先从$GOPATH初始化$ dep init -gopath -v 该命令会先从 Gopkg.toml该文件由 required = ["github.com/user/thing/cmd/thing"] ignored = [ "github.com/user/project/pkgX","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" # Recommended: the version constraint to enforce for the 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. source = "https://github.com/myfork/package.git" # 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该文件由 # This file is autogenerated,do not edit; changes may be undone by the next 'dep ensure'. [[projects]] branch = "master" name = "github.com/golang/protobuf" packages = [ "jsonpb","proto","protoc-gen-go/descriptor","ptypes","ptypes/any","ptypes/duration","ptypes/struct","ptypes/timestamp" ] revision = "bbd03ef6da3a115852eaf24c8a1c46aeb39aa175" 常用命令dep ensure从项目中的 用于确保本地的关系图、锁、依赖包清单完全一致 dep ensure -add# 引入该依赖包的最新版本 dep ensure -add github.com/pkg/foo # 引入具有特定约束(指定版本)的依赖包 dep ensure -add github.com/pkg/foo@^1.0.1 dep ensure -update将 最后目前 如果出现什么问题,大家可以一起留个言讨论讨论 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |