Glide command, how to use Glide,glide.lock

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Preview Catalog

  • Glide Create (alias Init)
  • Glide Config-wizard
  • Glide get [Package name]
  • Glide update (alias up)
  • Glide Install
  • Glide Novendor (alias NV)
  • Glide name
  • Glide list
  • Glide Help
  • Glide–version
  • Glide Mirror

Here are the glide commands, most of which are to help you manage your workspace.

Glide Create (alias Init)

Initializes a new workspace. In addition, this creates a glide.yaml file while trying to guess the package and version. For example, if your project uses GODEP, it will use the version specified by GODEP. Glide is smart enough to scan your code base to detect the package you are using, whether or not you specify a different packages manager.

$ glide Create[info] Generating a YAML configuration file and guessing the Dependencies[info] attempting to import from Other package managers (with--skip-import to skip) [INFO] scanning code to look for Dependencies[info]--Found refer ence to Github.com/masterminds/semver[info]--Found reference to Github.com/masterminds/vcs[info]--Found Refe Rence to Github.com/codegangsta/cli[info]--Found reference to Gopkg.in/yaml.v2[info] Writing configuration file (g LIDE.YAML) [INFO] Would you like Glide to help you find ways to improve your GLIDE.YAML configuration?  [INFO] If you want to revisit this step your can use the Config-wizard command at any time.  [INFO] Yes (Y) or No (N)? N[info] You can now edit the Glide.yaml file. Consider:[info]--Using versions and ranges. See Https://glide.sh/docs/versions/[info]-Adding additional metadata. See Https://glide.sh/docs/glide.yaml/[info]-Running the Config-wizard command to improve the versions in your Configuration 

The configuration wizards mentioned here can be run here or manually later. This wizard helps you find out which versions and scopes are available for dependencies.

Glide Config-wizard

This will run a wizard that scans the dependencies and retrieves the information on them to provide suggestions that can be interactively selected. For example, it can discover whether a dependency is using a semantic version and help you choose the version range you want to use.

Glide get [Package name]

You can glide get download one or more packages to your vendor directory and automatically add them to the glide.yml file.

$ glide get github.com/Masterminds/cookoo

When used glide get , it will introspect the packages listed to resolve its dependencies, including the use of Godep,gpm,gom and GB configuration files.

glide getA command can pass a version or range using the package name. For example:

$ glide get github.com/Masterminds/cookoo#^1.2.3

The version is separated from the package name by an anchor ( ). If you do not specify a version or range, and the dependency makes the semantic version Glide will prompt you to ask if you want to use them.

Glide update (alias up)

Download or update glide.yml all the libraries listed in the file and place them in the vendor directory. It will also recursively traverse the dependent package to get any desired configuration and read it in any configuration.

$ glide up

This will recursively look for packages that are managed by Glide,godep,gb,gom and gpm for other projects. When these packages are found, the packages are installed as needed.

The file is created or updated glide.lock , and the dependencies are pinned to a specific version. For example, if you specify a version in a glide.yaml file as a range (for example, ^ 1.2.3 ), it is set to a glide.lock specific commit identity in the file. This allows for repeatable installation (see glide install ).

To remove any nested directories from the extracted packages vendor/ , see -v flags.

Glide Install

Use when you want to glide.lock install a specific version from a file glide install .

$ glide install

This will read the glide.lock file and warn you if it is not bound to a glide.yaml file and installs a commit ID specific version.

When glide.lock a file is not bound to glide.yaml a file, it will provide a warning if there is a change. The run glide up will re-create the file when the dependency tree is updated glide.lock .

If no glide.lock file exists, glide install the update lock file is executed and generated.

To remove any nested directories from the extracted packages vendor/ , see -v flags.

Glide Novendor (alias NV)

When you run go test ./... such a command, it iterates through all subdirectories, including the vendor directory. When you test your application, you may want to test your application files without having to run the tests for all dependencies and their dependencies. This is novendor where the order came in. It lists vendor all except the directories.

$ go test $(glide novendor)

This will run for all directories ( vendor except directories) of your project go test .

Glide name

When you use Glide to write scripts, sometimes you need to know the name of the package you are using. glide namereturns the glide.yaml name of the package listed in the file.

Glide list

The Glide list command displays an alphabetical list of all packages imported by the project.

$ glide listINSTALLED packages:    vendor/github.com/Masterminds/cookoo    vendor/github.com/Masterminds/cookoo/fmt    vendor/github.com/Masterminds/cookoo/io    vendor/github.com/Masterminds/cookoo/web    vendor/github.com/Masterminds/semver    vendor/github.com/Masterminds/vcs    vendor/github.com/codegangsta/cli    vendor/gopkg.in/yaml.v2

Glide Help

Print Glide Help

$ glide help

Glide–version

Display version Information

$ glide --versionglide version 0.12.0

Glide Mirror

Mirroring provides the ability to replace a repo location with another location as the original mirror. This is useful when you want to have a cache for a continuous integration (CI) system, or if you want to work on a dependency on a local location.

The image is stored in GLIDE_HOME a mirrors.yaml file in.

Three commands to the manager image 是list , set and remove .

Use in forms set :

glide mirror set [original] [replacement]

Or

glide mirror set [original] [replacement] --vcs [type]

For example:

$ glide mirror set https://github.com/example/foo https://git.example.com/example/foo.git$ glide mirror set https://github.com/example/foo file:///path/to/local/repo --vcs git

Please use in the form remove :

glide mirror remove [original]

For example:

$ glide mirror remove https://github.com/example/foo

This article links: https://deepzz.com/post/glide-package-management-command.html, participating in the comments»

--eof--

Posted in 2017-02-09 22:36:00, and added "glide, Golang package Management" tab.

This site uses the "Signature 4.0 International" Creative sharing agreement, reproduced please specify the author and the original website. More Instructions»

Reminder: This article was last updated 199 days ago, the information described in the article may have changed, please use it carefully.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.