当前位置:网站首页>Golang project dependency management tool go vendor, go Mod
Golang project dependency management tool go vendor, go Mod
2022-06-25 14:00:00 【Leo Han】
We're doing golang When programming a project , Generally, we will face more complicated golang The problem of dependence , Can pass go vendor perhaps go mod To solve
If go get error , Make the following settings on the command line :
go env -w GOPROXY=https://goproxy.cn,direct
First download govendor:
go get github.com/kardianos/govendor
After downloading , Go to the project root , Perform initialization :
govendor init
govendor Common commands
| command | describe |
|---|---|
| init | Initial change vendor Catalog |
| list | List all the dependent packages of the project |
| add | Add package to vendor Under the table of contents |
| update | to update GOPATH Dependency package to vendor Catalog |
| remove | from vendor Delete dependent packages in |
| status | List the status of all packages : defect 、 Expired or changed packages |
| fetch | Add or update packages to local vendor Catalog |
| sync | according to vendor.json To update dependent packages |
| get | similar go get, Pull the dependency package to vendor Under the table of contents |
have access to govendor fetch Pull the source code directly :
govendor fetch github.com/go-gorm/gorm/
go mod Must be go 1.11 Version and above
Set it first :
go env -w GOBIN=/Users/youdi/go/bin
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct // Use seven cow cloud
go mod command
| command | explain |
|---|---|
| download | download modules to local cache( Download dependency package ) |
| edit | edit go.mod from tools or scripts( edit go.mod) |
| graph | print module requirement graph ( Print module dependency graph ) |
| verify | initialize new module in current directory( Initialize... In the current directory mod) |
| tidy | add missing and remove unused modules( Pull the missing module , Remove unused modules ) |
| vendor | make vendored copy of dependencies( Copy dependency to vendor Next ) |
| verify | verify dependencies have expected content ( Verify that the dependency is correct ) |
| why | explain why packages or modules are needed( Explain why you need to rely ) |
Initialize project :
// Go to the project root , perform :
go mod init
// perhaps go mod init Project name
```
And then you can use `go get` Pull the package that you need to depend on , Will be automatically go.mod Generate records in
- go mod download Download module to local cache , The cache path is $GOPATH/pkg/mod/cache
- go mod edit Yes, it provides command edition editing go.mod The function of , for example go mod edit -fmt go.mod Can format go.mod
- go mod graph Show the dependency graph between modules
- go mod init Initialization module ( For example, the original dep Managed dependencies are transformed )
- go mod tidy Add missing packages , Remove useless packages
- go mod vendor Copy dependencies to vendor/ Under the table of contents
- go mod verify Confirm dependencies
- go mod why Explain why packages and modules are needed
Generally, we can import other people's projects , Or modified go.mod After the document passed :
```
go mod tidy
```
To initialize the dependencies of the latter refresh project
If you use goland To develop , Then you need to set go module and go proxy agent :

边栏推荐
- The starting point for learning programming.
- Win7显示屏幕亮度在哪里可以调节
- Method for wrapping multiple promise instances into a new promise instance
- 关于STM32使用LAN8720A插拔网线重连
- 哈希表、哈希冲突
- shell 运算符
- shell 变量 入门
- Class usage and inheritance in ES6
- Is qiniu regular? Is it safe to open a stock account?
- Application of tactile intelligent sharing-rk3568 in financial self-service terminal
猜你喜欢

Solving error: creating window glfw error: glew initialization error: missing GL version

多台云服务器的 Kubernetes 集群搭建

Installation and removal of MySQL under Windows

112页机器学习-数学基础回顾.pptx

When the input tag type is number, the input of E, e, -, + is blocked

Knowledge of initial C language 2.0

K-line diagram 24 classic diagrams (shadow)

shell 数组
![leetcode:918. Maximum sum of circular subarray [reverse thinking + maximum subarray sum]](/img/2c/c5386b126ead9676894b18455aa5bd.png)
leetcode:918. Maximum sum of circular subarray [reverse thinking + maximum subarray sum]

Discuz仿今日头条模板/Discuz新闻资讯商业版GBK模板
随机推荐
The priority of catch() and then (..., ERR) of promise
Hash table, hash conflict
"Mobile cloud Cup" computing power network application innovation competition is in hot registration!
How to configure aliases for typescript + vite projects
Asp.net WebForm使用NPOI导出Excel
Is qiniu regular? Is it safe to open a stock account?
Sigmoid function sigmoid derivation
sql导入这样怎么解决
shell 变量 入门
Installation and removal of MySQL under Windows
启牛是正规的吗?股票开户安全吗?
As a software testing engineer, how do you think to ensure software quality?
Graph contractual learning with augmentations
Is it safe for Guosen Securities to open a stock account? Excuse me?
戴尔电脑cpu温度过高怎么办
一次性讲清楚 Handler 可能导致的内存泄漏和解决办法 | 开发者说·DTalk
哈希錶、哈希沖突
权益NFT开创者Hash Eagle如何重新定义NFT,用权益赋能长续价值?
NVM installation and use tutorial
‘nvidia-smi‘ 不是内部或外部命令,也不是可运行的程序或批处理文件