Go 包管理工具--glide
阿新 • • 發佈:2018-11-05
網上有一篇解釋glide比較好的文章:https://my.oschina.net/u/553243/blog/1475626
在命令列中輸入glide
$glide NAME: glide - Vendor Package Management for your Go projects. Each project should have a 'glide.yaml' file in the project directory. Files look something like this: package: github.com/Masterminds/glide imports: - package: github.com/Masterminds/cookoo version: 1.1.0 - package: github.com/kylelemons/go-gypsy subpackages: - yaml For more details on the 'glide.yaml' files see the documentation at https://glide.sh/docs/glide.yaml USAGE: glide [global options] command [command options] [arguments...] VERSION: D0.1.22 COMMANDS: create, init Initialize a new project, creating a glide.yaml file config-wizard, cw Wizard that makes optional suggestions to improve config in a glide.yaml file. get Install one or more packages into `vendor/` and add dependency to glide.yaml. remove, rm Remove a package from the glide.yaml file, and regenerate the lock file. import Import files from other dependency management systems. name Print the name of this project. novendor, nv List all non-vendor paths in a directory. rebuild Rebuild ('go build') the dependencies install, i Install a project's dependencies update, up Update a project's dependencies tree (Deprecated) Tree prints the dependencies of this project as a tree. list List prints all dependencies that the present code references. info Info prints information about this project cache-clear, cc Clears the Glide cache. about Learn about Glide mirror Manage mirrors help, h Shows a list of commands or help for one command GLOBAL OPTIONS: --yaml value, -y value Set a YAML configuration file. (default: "glide.yaml") --quiet, -q Quiet (no info or debug messages) --debug Print debug verbose informational messages --home value The location of Glide files (default: "/Users/didi/.glide") [$GLIDE_HOME] --tmp value The temp directory to use. Defaults to systems temp [$GLIDE_TMP] --no-color Turn off colored output for log messages --help, -h show help --version, -v print the version
上述命令中有關於glide命令的解釋。
經常用到的幾個命令
glide get 會將依賴的包安裝到當前專案的vendor/目錄下,同時將依賴說明新增到glide.yaml。
$glide get github.com/Masterminds/glide
## get Install one or more packages into `vendor/` and add dependency to glide.yaml.
glide get --all-dependencies 拉取指定包的所有依賴包。
command: glide get --all-dependencies -s -v github.com/mattn/go-adodb glide.lock: hash: 60061bf3133f0eec2f147f3d80f3e37c402ee12df8cde841b03d80c82a96bab7 updated: 2016-05-18T23:34:48.7545322+08:00 imports: - name: github.com/go-ole/go-ole version: 572eabb84c424e76a0d39d31510dd7dfd62f70b2 subpackages: - oleutil - name: github.com/gonuts/commander version: f8ba4e959ca914268227c3ebbd7f6bf0bb35541a - name: github.com/gonuts/flag version: 741a6cbd37a30dedc93f817e7de6aaf0ca38a493 - name: github.com/mattn/go-adodb version: 452cccbbcfb7906b3cbc512992557c1083e1011b devImports: [] glide.yaml: package: glide_demo6 import: - package: github.com/mattn/go-adodb
拉取制定依賴包
command:
glide get github.com/go-sql-driver/mysql#v1.2
glide.yaml:
package: glide_demo
import:
- package: github.com/go-sql-driver/mysql
version: v1.2
glide up 更新依賴包中的程式碼版本
glide install 安裝依賴包中的程式碼。
glide rm 刪除制定依賴包