当前位置:网站首页>【GO】go mod 和vendor依赖管理工具
【GO】go mod 和vendor依赖管理工具
2022-08-06 15:55:00 【weixin_43224306】
go module是Go语言默认的依赖管理工具,且没有必要在GOPATH中创建项目了。
常用命令:
go mod init 初始化当前文件夹, 创建go.mod文件
go mod download/go get 下载依赖的module到本地cache(默认为$GOPATH/pkg/mod目录)
go mod graph 打印模块依赖图
go mod tidy 增加缺少的module,删除无用的module
go mod verify 校验依赖
go get [email protected] 下载指定version的包
在go module中,
module定义包名,indirect表示间接引用
require:依赖包列表以及版本
exclude:禁用依赖包列表
replace:替换依赖包列表
go mod模式下设置proxy代理后,go get或go mod download下载的源码会存在$GOPATH/pkg/mod目录下,go get下载后,go mod可能会莫名其妙的找不到(编译器会首先查找Go的安装目录下的src和pkg,然后才会查找GOPATH的pkg或src),可以手动再添加到gomod中一次解决:
go mod init gin
go mod edit -require github.com/gin-gonic/[email protected] (添加gin依赖)
govendor的使用
govendor init 初始化生成vendor文件夹,代码必须写在proj/src下,即proj/src/main.go
govender add +all 将Path/src下的包拷贝到vendor目录
边栏推荐
猜你喜欢
随机推荐
13. Implementation of paging loading datasets for SAP ABAP OData service (Paging)
社区人物志 | 朱小力:Doris 社区新鲜力量
LeetCode:21. 合并两个有序链表————简单
重构指标之如何监控代码圈复杂度
04、GO模块与包、结构体
直播声卡怎么做CE认证
Ant Group builds the industry's first full-picture risk control and explains the technical architecture in detail for the first time
无辅源电流继电器HDLN-1-2H
LeetCode:205. 同构字符串————简单
JGL-15/5反时限过流继电器
普林斯顿微积分读本04第三章--极限导论
启牛帮开通的中信证券VIP账户是安全的吗?怎么开
Auto.js 如何把图片和脚本一起打包,或者打包多个脚本
LeetCode:206. 反转链表————简单
全排列问题
SQL执行一次完成新增或者修改操作-2022新项目
PC 真的不行了!Intel、AMD 同遭生死劫
HJLL-99/A数字零序电流继电器
Unstoppable, a major breakthrough in China's chip manufacturing industry chain, 5nm equipment will soon be sent to TSMC
SAP BAPI 教程 – 在 ABAP 中创建 BAPI 的分步指南-020









