Golang包管理-vendor
Vendor目錄介紹
Golang 官方並沒有推薦最佳的包管理方案。到了1.5版本時代,官方引入包管理的設計,加了 vendor 目錄來支援本地包管理依賴。官方 wiki 推薦了多種支援這種特性的包管理工具,如:Godep、gv、gvt、glide、govendor等。即使使用vendor,也必須在GOPATH中。
查詢依賴包路徑的順序
- 當前包下的vendor目錄。
- 向上級目錄查詢,直到找到src下的vendor目錄。
- 在GOPATH下面查詢依賴包。
- 在GOROOT目錄下查詢
包管理工具govendor
需要把 $GOPATH/bin/ 加到 PATH 中。
安裝
go get -u github.com/kardianos/govendor
命令
init建立 vendor 資料夾和 vendor.json 檔案 list列出已經存在的依賴包 add從 $GOPATH 中新增依賴包,會加到 vendor.json update從 $GOPATH 升級依賴包 remove從 vendor 資料夾刪除依賴 status列出本地丟失的、過期的和修改的package fetch從遠端庫增加新的,或者更新 vendor 檔案中的依賴包 syncPull packages into vendor folder from remote repository with revisions migrateMove packages from a legacy tool to the vendor folder with metadata. get類似 go get,但是會把依賴包拷貝到 vendor 目錄 licenseList discovered licenses for the given status or import paths. shellRun a "shell" to make multiple sub-commands more efficient for large projects. go tool commands that are wrapped: `+<status>` package selection may be used with them fmt, build, install, clean, test, vet, generate, tool
其他工具參考
等以後嘗試一下。