当前位置:网站首页>Golang must know the Go Mod command
Golang must know the Go Mod command
2022-07-31 21:35:00 【m0_67401228】
Golang must know Go Mod commands
Golang is easy to learn
Article Directory
I. What is go mod?
Go modules are officially defined as:
A module is a collection of related Go packages.Modules are the unit of source code exchange and version control.
The go command directly supports the use of modules, including logging and resolving dependencies on other modules.modules replace the old GOPATH-based method of specifying which source files to use in a given build.
Second, detailed commands
1.init
Code:
go mod init
Generate a go.mod file. This command will initialize and create a new go.mod file in the current directory. Manually creating a go.mod file and including some module declarations is also equivalent to this command, and the go mod init command isHelp us make it easy, you can help us create it automatically.
2.download
Code:
go mod download
Download all dependencies specified in the go.mod file. Use this command to download the specified module. The format of the module can be specified according to the form of the main module dependency or the form of [email protected]
3.tidy
Code:
go mod tidy
Organize existing dependencies, use this command to download the specified module, and delete the modules that are no longer used
4.graph
Code:
go mod graph
View the existing dependency structure and generate a report of all dependencies of the project, but the readability is too poor, and the graphics are more convenient.
5.edit
Code:
go mod edit
Edit the go.mod file, then download or edit it
5.vendor
Code:
go mod vendor
Export all dependencies of the project to the vendor directory, copy from the mod to the vendor directory of the project, the IDE can recognize such a directory.
5.verify
Code:
go mod verify
Check whether a module has been tampered with, and check whether a common module error has been tampered with
5.why
Code:
go mod why
Check why you need to depend on a module, and check whether an uncommon module is a reference of which module
Summary
Through the above, it is easy to understand how to use go mod in Golang.Go mod provides a series of commands for manipulating modules, and module support is now built into all go commands, not just go mod commands.For example, when using go get, dependency package versions are often automatically added, removed, upgraded, and downgraded in the background.
Hope this blog will be useful to you.I am the King of Light, and I speak for myself.
Let me introduce myself first. The editor graduated from Shanghai Jiaotong University in 2013. I worked in a small company and went to big factories such as Huawei and OPPO. I joined Alibaba in 2018, until now.I know that most junior and intermediate java engineers want to upgrade their skills, they often need to explore their own growth or sign up to study, but for training institutions, the tuition fee is nearly 10,000 yuan, which is really stressful.Self-learning that is not systematic is very inefficient and lengthy, and it is easy to hit the ceiling and the technology stops.Therefore, I collected a "full set of learning materials for java development" for everyone. The original intention is also very simple. I hope to help friends who want to learn by themselves but don't know where to start, and at the same time reduce everyone's burden.Add the business card below to get a full set of learning materials
边栏推荐
- [Intensive reading of the paper] iNeRF
- Basic configuration of OSPFv3
- SiC MOSFET的短路特性及保护
- What's wrong with the sql syntax in my sql
ojdbc8 "Recommended Collection"- 广汽本田安全体验营:“危险”是最好的老师
- 请问我的这段sql中sql语法哪里出了错
- Pytorch lstm time series prediction problem stepping on the pit "recommended collection"
- Commonly used security penetration testing tools (penetration testing tools)
- 第七章
猜你喜欢

Memblaze发布首款基于长存颗粒的企业级SSD,背后有何新价值?

Three. Introduction to js

如何才能真正的提高自己,成为一名出色的架构师?

Teach you how to deploy Nestjs projects

How programmers learn open source projects, this article tells you

全网一触即发,自媒体人的内容分发全能助手——融媒宝

TestCafeSummary

Redis Overview: Talk to the interviewer all night long about Redis caching, persistence, elimination mechanism, sentinel, and the underlying principles of clusters!...

iNeuOS industrial Internet operating system, equipment operation and maintenance business and "low-code" form development tools

Go mode tidy reports an error go warning “all” matched no packages
随机推荐
C language parsing json string (json object is converted to string)
BOW/DOM (top)
高通cDSP简单编程例子(实现查询高通cDSP使用率、签名),RK3588 npu使用率查询
Given an ip address, how does the subnet mask calculate the network number (how to get the ip address and subnet mask)
cas and spin locks (is lightweight locks spin locks)
idea中搜索具体的字符内容的快捷方式
flowable workflow all business concepts
The principle of ReentrantLock (to be continued)
嵌入式开发没有激情了,正常吗?
OSPFv3的基本配置
【公开课预告】:超分辨率技术在视频画质增强领域的研究与应用
Three. Introduction to js
Architect 04 - Application Service Encryption Design and Practice
[Code Hoof Set Novice Village 600 Questions] Leading to the combination of formulas and programs
[Code Hoof Set Novice Village 600 Questions] Merge two numbers without passing a character array
Performance optimization: remember a tree search interface optimization idea
Structure of the actual combat battalion module eight operations
leetcode 665. Non-decreasing Array
Thymeleaf是什么?该如何使用。
ReentrantLock原理(未完待续)