go mod 解决 Go 语言的包依赖问题
转:https://testerhome.com/topics/16980
----------------------------------------------
go mod 解决 Go 语言的包依赖问题
受众
学习过Go的人,入门即可
go mod命令
随着Go 1.11的发布,go开始支持mod子命令
这个命令解决了Go依赖更新的问题。刚开始学起来有一点难度,不过学会了之后,会发现这玩意比原来的 vendor好太多。
官方还专门弄了一个https://goproxy.io网站,专门方便我们这些国内的用户。
先看下自带的帮助。
$ go mod
Go mod provides access to operations on modules.
Note that support for modules is built into all the go commands,
not just 'go mod'. For example, day-to-day adding, removing, upgrading,
and downgrading of dependencies should be done using 'go get'.
See 'go help modules' for an overview of module functionality.
Usage:
go mod <command> [arguments]
The commands are:
download download modules to local cache
edit edit go.mod from tools or scripts
graph print module requirement graph
init initialize new module in current directory
tidy add missing and remove unused modules
vendor make vendored copy of dependencies
verify verify dependencies have expected content
why explain why packages or modules are needed
Use "go help mod <command>" for more information about a command.
想学好go mod命令,推荐3篇文章,阅读顺序有先后。
https://roberto.selbach.ca/intro-to-go-modules/
这是Roberto Selbach大神写的这篇 Step by step的 go mod入门文章,非常好理解
https://github.com/golang/go/wiki/Modules
go mod的官方文档,想了解的多一点最好还是通读一下
https://roberto.selbach.ca/go-proxies/
最后还有一篇介绍GOPROXY的文章,比较适合对go mod熟悉之后再看
使用感受
感觉go mod应该是受了 npm 的package.json 启发,总体而言比过去的vendor好了很多,但是如果要修改依赖库,还需要再重新发布个版本,感觉调试起来不是很方便。
go mod 解决 Go 语言的包依赖问题的更多相关文章
- 解决使用Idea/Eclipse编写Hadoop程序包依赖问题
解决使用Idea/Eclipse编写Hadoop程序包依赖问题 解决包依赖的一种简单粗暴方法就是, 把下载下来的Hadoop压缩包解压, 搜索里面所有的额jar包文件,然后复制到一个目录,在使用Ide ...
- 解决jar包依赖:Spring IO platform推出bom
名词解释: BOM(bill of materials):材料清单,用于解决jar包依赖的好方法. Spring IO Platform 缘起:Spring起初只专注ioc和aop,现在已发展成一个庞 ...
- 【maven】排除maven中jar包依赖的解决过程 例子:spring cloud启动zipkin,报错maven依赖jar包冲突 Class path contains multiple SLF4J bindings.
一直对于maven中解决jar包依赖问题的解决方法纠结不清: 下面这个例子可以说明一个很简单的解决方法: 项目启动报错: Connected to the target VM, address: '1 ...
- Java-idea-常用技巧-转maven,解决包依赖冲突
1.Intellij IDEA如何将普通工程转换成maven工程 项目上右键 Add Framework Support,选择maven 2.Intellij IDEA 自动生成 serialVers ...
- mavn jar包依赖冲突解决
背景:使用maven很方便,但是引入冲突也很常见.后果很严重,各种不明实体找不到,所以需要对jar包的依赖有一个清晰的认识. 查看冲突 参考:用dependency:tree查看maven引入jar包 ...
- IDEA从Github中Clone Maven项目,解决树形目录及Jar包依赖的问题
很多人在开发中都会碰到的一个问题,当我们用IDEA从Github中检出Maven工程后(Java),发现既不能运行,也不能编译,左侧的树形目录还怪怪的,现在就来说说如何解决这个问题. IDEA从git ...
- xmake v2.5.7 发布,包依赖锁定和 Vala/Metal 语言编译支持
xmake 是一个基于 Lua 的轻量级跨平台构建工具,使用 xmake.lua 维护项目构建,相比 makefile/CMakeLists.txt,配置语法更加简洁直观,对新手非常友好,短时间内就能 ...
- ubuntu遇到包依赖问题出错的解决方法
更新时遇到了libc6包依赖错误,甚至“sudo apt-get -f install“也会报错, 这时候可以使用下列命令删除包后重新安装dpkg -r --force-all 包名称 然后再sudo ...
- idea在maven中引入了jar包依赖,但是编译过程中报出XXX程序包不存在,已解决
idea在maven中引入了jar包依赖,但是编译过程中报出XXX程序包不存在 1. 报错具体情况 2. Project Structure中的Libraries没有任何红色波浪线 3. 发现自己要引 ...
随机推荐
- Zookeeper概述、特点、数据模型
Zookeeper 1.Zookeeper概述 Zookeeper是一个工具,可以实现集群中的分布式协调服务. 所谓的分布式协调服务,就是在集群的节点中进行可靠的消息传递,来协调集群的工作. Zo ...
- sort(()=>{return Math.random()-0.5)}乱序数组不准确
为什么sort(()=>{return Math.random()-0.5)}乱序数组不准确.(注意结合插入排序原理来理解) @1.chrome浏览器对于数组长度10以内为插入排序.反之则快速排 ...
- POJ 2195 Going Home 【最小费用最大流】
题目链接:http://poj.org/problem?id=2195 Time Limit: 1000MS Memory Limit: 65536K Total Submissions:2715 ...
- 2.1spring cloud 环境配置
前提:SpringBoot可以离开SpringCloud独立使用开发项目,但是SpringCloud离不开SpringBoot,属于依赖的关系. 所以基本是搭建SpringBoot + 组件 = Sp ...
- 安装sqlserver导致80端口被占用解决方法
安装sqlserver导致80端口被占用解决方法 系统占用的端口一般都是微软官方的产品占用的.所以这个时候主要考虑到几个服务: SQL Server导致.其中很有可能是SQL Server Repor ...
- linux命令自动补全
在linux中命令较长时,不易记忆,使用命令行自动补全,使用方便,配置方法记录如下 需要安装bash-completion 重启后生效 命令:yum install bash-completion,安 ...
- 怎样理解JS的预解析机制
JS的预解析包括两部分: 1. 变量提升 2. 函数声明 对于变量提升, 可以看下下面这块代码 console.log(name); // undefined var name = "Lil ...
- windows下将jar包打入maven仓库
mvn install:install-file -DgroupId=org.csource -DartifactId=fastdfs-client-java -Dversion=1.27 -Dpac ...
- Java生成随机数列表
生成随机数列表 1.Java8以前 (1)Math.random private List<UserEntity> random1() { ArrayList<UserEntity& ...
- C# 32位系统与64位系统调用不同的DLL文件
string dll32 = System.Windows.Forms.Application.StartupPath + @"\System.Data.SQLite-32.DLL" ...