Golang包管理工具(二)之glide的使用

野性酷女 2022-05-31 23:11 307阅读 0赞

更多golang包管理工具参考
- dep的使用
- glide的使用
- govendor的使用

1. glide简介

glide是一个golang项目的包管理工具,非常方便快捷,一般只需要2-3个命令就可以将go依赖包自动下载并归档到vendor的目录中。glide官网参考:https://glide.sh/

2. glide安装

  1. go get github.com/Masterminds/glide

3. glide使用

  1. #进入到项目目录
  2. cd /home/gopath/src/demo
  3. #glide初始化,初始化配置文件glide.yaml
  4. glide init
  5. #glide加载依赖包,自动归档到vendor目录
  6. glide up -v

4. glide的配置文件

glide.yaml记录依赖包列表。

  1. package: demo
  2. import:
  3. - package: github.com/astaxie/beego
  4. version: v1.9.2
  5. testImport:
  6. - package: github.com/smartystreets/goconvey
  7. version: 1.6.3
  8. subpackages:
  9. - convey

5. glide-help

更多glide的命令帮助参考glide —help

  1. demo glide --help
  2. NAME:
  3. glide - Vendor Package Management for your Go projects.
  4. Each project should have a 'glide.yaml' file in the project directory. Files
  5. look something like this:
  6. package: github.com/Masterminds/glide
  7. imports:
  8. - package: github.com/Masterminds/cookoo
  9. version: 1.1.0
  10. - package: github.com/kylelemons/go-gypsy
  11. subpackages:
  12. - yaml
  13. For more details on the 'glide.yaml' files see the documentation at
  14. https://glide.sh/docs/glide.yaml
  15. USAGE:
  16. glide [global options] command [command options] [arguments...]
  17. VERSION:
  18. 0.13.2-dev
  19. COMMANDS:
  20. 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/meitu/.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

发表评论

表情:
评论列表 (有 0 条评论,307人围观)

还没有评论,来说两句吧...

相关阅读