当前位置:网站首页>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-20d25e280405
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
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.16
2, 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
边栏推荐
猜你喜欢
挡不住了,国产芯片再度突进,部分环节已进到4nm
PhpMyAdmin stage file contains analysis traceability
SQL Injection (GET/Select)
JVM系列——概述,程序计数器day1-1
Multi table query of MySQL - multi table relationship and related exercises
Internet of things completion -- (stm32f407 connects to cloud platform detection data)
Brief analysis of tensorboard visual processing cases
双向链表(我们只需要关注插入和删除函数)
106. How to improve the readability of SAP ui5 application routing URL
MySQL 数据处理值增删改
随机推荐
php 迷宫游戏
Several common optimization methods matlab principle and depth analysis
Tutoriel PowerPoint, comment enregistrer une présentation sous forme de vidéo dans Powerpoint?
Go language unit test 3: go language uses gocovey library to do unit test
SQL Injection (GET/Select)
Road construction issues
双向链表(我们只需要关注插入和删除函数)
Anan's doubts
R language uses the data function to obtain the sample datasets available in the current R environment: obtain all the sample datasets in the datasets package, obtain the datasets of all packages, and
PowerPoint tutorial, how to save a presentation as a video in PowerPoint?
父亲和篮球
Shell timing script, starting from 0, CSV format data is regularly imported into PostgreSQL database shell script example
物联网毕设 --(STM32f407连接云平台检测数据)
双链笔记 RemNote 综合评测:快速输入、PDF 阅读、间隔重复/记忆
Comprehensively develop the main channel of digital economy and digital group, and actively promote the utonmos digital Tibet market
Bidirectional linked list (we only need to pay attention to insert and delete functions)
记录关于银行回调post请求405 问题
[556. Next larger element III]
JSON serialization case summary
8皇后问题