1. glide简介

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

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
  21. config-wizard, cw Wizard that makes optional suggestions to improve config in a glide.yaml file.
  22. get Install one or more packages into `vendor/` and add dependency to glide.yaml.
  23. remove, rm Remove a package from the glide.yaml file, and regenerate the lock file.
  24. import Import files from other dependency management systems.
  25. name Print the name of this project.
  26. novendor, nv List all non-vendor paths in a directory.
  27. rebuild Rebuild ('go build') the dependencies
  28. install, i Install a project's dependencies
  29. update, up Update a project's dependencies
  30. tree (Deprecated) Tree prints the dependencies of this project as a tree.
  31. list List prints all dependencies that the present code references.
  32. info Info prints information about this project
  33. cache-clear, cc Clears the Glide cache.
  34. about Learn about Glide
  35. mirror Manage mirrors
  36. help, h Shows a list of commands or help for one command
  37. GLOBAL OPTIONS:
  38. --yaml value, -y value Set a YAML configuration file. (default: "glide.yaml")
  39. --quiet, -q Quiet (no info or debug messages)
  40. --debug Print debug verbose informational messages
  41. --home value The location of Glide files (default: "/Users/meitu/.glide") [$GLIDE_HOME]
  42. --tmp value The temp directory to use. Defaults to systems temp [$GLIDE_TMP]
  43. --no-color Turn off colored output for log messages
  44. --help, -h show help
  45. --version, -v print the version