golang學習筆記-go mod的使用
阿新 • • 發佈:2020-11-14
1.go modules的基本介紹
1.1 提供的命令
在go環境的shell中執行go mod help檢視命令和說明。
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 initializenew 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
命令 | 作用 |
| 下載模組到本地快取,快取路徑是$GOPATH/pkg/mod/cache |
go mod edit |
是提供了命令版編輯go.mod 的功能,例如go mod edit -fmt go.mod 會格式化go.mod |
go mod graph | 把模組之間的依賴圖顯示出來 |
|
初始化模組(例如把原本dep管理的依賴關係轉換過來) |
|
增加缺失的包,移除沒用的包 |
|
把依賴拷貝到vendor/ 目錄下 |
|
確認依賴關係 |
|
解釋為什麼需要包和模組 |