Golang开发Go依赖管理工具dep安装验证实现过程是什么
发表于:2024-10-23 作者:千家信息网编辑
千家信息网最后更新 2024年10月23日,这篇文章主要讲解了"Golang开发Go依赖管理工具dep安装验证实现过程是什么",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"Golang开发Go依赖
千家信息网最后更新 2024年10月23日Golang开发Go依赖管理工具dep安装验证实现过程是什么
这篇文章主要讲解了"Golang开发Go依赖管理工具dep安装验证实现过程是什么",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"Golang开发Go依赖管理工具dep安装验证实现过程是什么"吧!
Go依赖管理工具
Go dependency management tool
环境要求
Golang >= 1.9Dep
目前版本
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/golang/dep/cmd/dep
若$GOPATH/bin
不在PATH
下,则需要将生成的dep
文件从$GOPATH/bin
移动至$GOBIAN
下
验证
$ depDep is a tool for managing dependencies for Go projectsUsage: "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 informationExamples: 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
在初始化时会分析应用程序所需要的所有依赖包,得出依赖包清单
并生成vendor
目录,Gopkg.toml
、Gopkg.lock
文件
默认初始化
$ dep init -v
直接从对应网络资源处下载
优先从$GOPATH初始化
$ dep init -gopath -v
该命令会先从$GOPATH
查找既有的依赖包,若不存在则从对应网络资源处下载
Gopkg.toml
该文件由dep init
生成,包含管理dep
行为的规则声明
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
该文件由dep ensure
和dep init
生成,包含一个项目依赖关系图的传递完整快照,表示为一系列[[project]]
节
# 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
从项目中的Gopkg.toml
和Gopkg.lock
中分析关系图,并获取所需的依赖包
用于确保本地的关系图、锁、依赖包清单完全一致
dep ensure -add
# 引入该依赖包的最新版本dep ensure -add github.com/pkg/foo # 引入具有特定约束(指定版本)的依赖包dep ensure -add github.com/pkg/foo@^1.0.1
dep ensure -update
将Gopkg.lock
中的约定依赖项更新为Gopkg.toml
允许的最新版本
感谢各位的阅读,以上就是"Golang开发Go依赖管理工具dep安装验证实现过程是什么"的内容了,经过本文的学习后,相信大家对Golang开发Go依赖管理工具dep安装验证实现过程是什么这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!
管理
验证
工具
管理工具
过程
开发
文件
版本
生成
命令
项目
学习
内容
清单
网络
网络资源
资源
一致
就是
常用
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
高端手机网络安全吗
通达信主题投资数据库
艾尔登法环无法登陆服务器ps4
网络安全密钥手机怎么看
word 隐藏数据库
估算软件开发工作量
网络安全五个一定要
海南卡罗地亚网络技术有限公司
美服测试服务器怎么样
软件开发工程专业介绍
宝山区威力网络技术要多少钱
数据库实验教程阅读心得
qnap文档服务器
支付宝网网络技术有限公司
中网络安全研究院
cnki的数据库有哪些
国产网络服务器机柜哪家好
安全测试前后端服务器信息泄露
服务器主文件夹有什么用
resset数据库
淄博联想服务器代理怎么收费
追星网络安全
上海睿网络科技有限公司互联网
广州网络技术与新媒体大学
电脑网络安全在哪学
抖音地方服务器
rabbitmq数据库
新基建的网络安全进展
传奇世界下载服务器
车载网络技术答案