当前位置:网站首页>Go 1.16.4: purpose of go mod tidy
Go 1.16.4: purpose of go mod tidy
2022-07-03 13:48:00 【Lao Liu, you are so awesome】
One , view help :
1, View original document
[email protected]:/data/go/mod3$ go help mod tidy
usage: go mod tidy [-e] [-v]
Tidy makes sure go.mod matches the source code in the module.
It adds any missing modules necessary to build the current module's
packages and dependencies, and it removes unused modules that
don't provide any relevant packages. It also adds any missing entries
to go.sum and removes any unnecessary ones.
The -v flag causes tidy to print information about removed modules
to standard error.
The -e flag causes tidy to attempt to proceed despite errors
encountered while loading packages.
See https://golang.org/ref/mod#go-mod-tidy for more about 'go mod tidy'.
2, explain : You can see go mod tidy Role of command :
Add required but go.mod Modules not found in ,
Delete unused modules
explain : Liu Hongdi's go The forest is a focus golang The blog of ,
Address :https://blog.csdn.net/weixin_43881017
explain : author : Liu Hongdi mailbox : [email protected]
Two , demonstration : Delete unused modules
1, see go.mod The content of :
[email protected]:/data/go/mod3$ more go.mod
module mod3
go 1.16
require github.com/gin-gonic/gin v1.7.2 // indirect
2, install gorm2
[email protected]:/data/go/mod3$ go get -u gorm.io/gorm
go: downloading gorm.io/gorm v1.21.10
go: downloading github.com/jinzhu/inflection v1.0.0
go: downloading github.com/jinzhu/now v1.1.2
go get: added gorm.io/gorm v1.21.10
View again go.mod
[email protected]:/data/go/mod3$ more go.mod
module mod3
go 1.16
require (
github.com/gin-gonic/gin v1.7.2 // indirect
gorm.io/gorm v1.21.10 // indirect
)
You can see gorm Has been added to go.mod
3, perform tidy Check the effect after the command
[email protected]:/data/go/mod3$ go mod tidy
go: downloading github.com/go-playground/assert/v2 v2.0.1
go: downloading gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405View again go.mod
[email protected]:/data/go/mod3$ more go.mod
module mod3
go 1.16
require github.com/gin-gonic/gin v1.7.2
You can see that because we haven't used the newly added gorm2,
therefore gorm2 The module is go mod tidy The command removed
3、 ... and , demonstration : Add used but go.mod Module that does not exist in :
1, Manual from go.mod Delete in gin Module reference
[email protected]:/data/go/mod3$ vi go.mod
Check... When you're done go.mod
[email protected]:/data/go/mod3$ more go.mod
module mod3
go 1.162, perform tidy
[email protected]:/data/go/mod3$ go mod tidy
go: finding module for package github.com/gin-gonic/gin
go: found github.com/gin-gonic/gin in github.com/gin-gonic/gin v1.7.2
View again go.mod
[email protected]:/data/go/mod3$ more go.mod
module mod3
go 1.16
require github.com/gin-gonic/gin v1.7.2 Because we used gin modular ,
therefore go mod tidy Automatically for us in go.mod Added what has just been added gin modular
Four , see go Version of :
[email protected]:/data/go/mod3$ go version
go version go1.16.4 linux/amd64
边栏推荐
- Mobile phones and computers can be used, whole people, spoof code connections, "won't you Baidu for a while" teach you to use Baidu
- DQL basic query
- Universal dividend source code, supports the dividend of any B on the BSC
- JVM系列——概述,程序计数器day1-1
- 研发团队资源成本优化实践
- The network card fails to start after the cold migration of the server hard disk
- Leetcode-1175.Prime Arrangements
- Typeerror resolved: argument 'parser' has incorrect type (expected lxml.etree.\u baseparser, got type)
- Comprehensive evaluation of double chain notes remnote: fast input, PDF reading, interval repetition / memory
- Resolved (error in viewing data information in machine learning) attributeerror: target_ names
猜你喜欢

The latest BSC can pay dividends. Any B usdt Shib eth dividend destruction marketing can

Brief analysis of tensorboard visual processing cases

Libuv库 - 设计概述(中文版)

SQL Injection (GET/Select)

PowerPoint 教程,如何在 PowerPoint 中將演示文稿另存為視頻?

Mobile phones and computers can be used, whole people, spoof code connections, "won't you Baidu for a while" teach you to use Baidu

Comprehensive evaluation of double chain notes remnote: fast input, PDF reading, interval repetition / memory
![[机缘参悟-37]:人感官系统的结构决定了人类是以自我为中心](/img/06/b71b505c7072d540955fda6da1dc1b.jpg)
[机缘参悟-37]:人感官系统的结构决定了人类是以自我为中心

Logback log sorting

Setting up remote links to MySQL on Linux
随机推荐
[technology development-24]: characteristics of existing IOT communication technology
栈应用(平衡符)
Golang — 命令行工具cobra
Golang - command line tool Cobra
网上开户哪家证券公司佣金最低,我要开户,网上客户经理开户安全吗
[understanding by chance-37]: the structure of human sensory system determines that human beings are self-centered
【电脑插入U盘或者内存卡显示无法格式化FAT32如何解决】
Open PHP error prompt under Ubuntu 14.04
服务器硬盘冷迁移后网卡无法启动问题
[développement technologique - 24]: caractéristiques des technologies de communication Internet des objets existantes
8皇后问题
Setting up remote links to MySQL on Linux
Kivy tutorial how to automatically load kV files
顺序表(C语言实现)
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
Internet of things completion -- (stm32f407 connects to cloud platform detection data)
Students who do not understand the code can also send their own token, which is easy to learn BSC
Error running 'application' in idea running: the solution of command line is too long
Go language unit test 3: go language uses gocovey library to do unit test
软件测试工作那么难找,只有外包offer,我该去么?