Golang Package Management tool Glide, you deserve to have

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

"Relying on hell" is the situation that every programmer will face on the way of growing up, first we control the software version through the semantic version, and then in our project through the designation 软件版本 to achieve the purpose of controlling dependence.

For example: Your project a relies on multiple project B1,B2,B3, and B1,B2,B3 relies on other projects c1,c2 .... A project relies on these multiple projects, when the project C1 fix bug version changes, if a is still using the old version, it is bound to cause unknown problems. So, you need to be aware of the importance of package dependency management.

In the go language, I recommend that you use glide as the package manager. It can automatically identify the Godeps package management, full of convenience. This section describes glide.yml the semantic description and 版本指定 the format.

GLIDE.YML file

glide.ymlIs the configuration file for the glide package management. glide.ymlThe following is a description of the relevant elements.

Here is a complete glide.yml file:

package: github.com/Masterminds/glidehomepage: https://masterminds.github.io/glidelicense: MITowners:- name: Matt Butcheremail: technosophos@gmail.comhomepage: http://technosophos.com- name: Matt Farinaemail: matt@mattfarina.comhomepage: https://www.mattfarina.comignore:- appengineexcludeDirs:- node_modulesimport:- package: gopkg.in/yaml.v2- package: github.com/Masterminds/vcsversion: ^1.2.0repo:    git@github.com:Masterminds/vcsvcs:    git- package: github.com/codegangsta/cliversion: f89effe81c1ece9c5b0fda359ebd9cf65f169a51- package: github.com/Masterminds/semverversion: ^1.0.0testImport:- package: github.com/arschles/assert

These elements are:

  • package: The package at the top is where it is GOPATH , and the glide will start with the guide from that location.

  • homepage: The details page of the project.

  • license: The license ID, which can be a SPDX license string or file path.

  • owners: Project owner information for easy access to vulnerability information.

  • ignore: Ignore the imported package, note that it is a package instead of a directory.

  • excludeDirs: Excludes directories that are dependent on the scan.

  • import: Import Package List:

  • package: The name of the imported package is required. The package name follows the same pattern used by the Go tool. This means: 1. The package name mapped to the VCS remote location ends with. git,.bzr,.hg or. svn. For example, example.com/foo/pkg.git/subpkg. 2, GitHub, BitBucket, Launchpad, IBM Bluemix Services, and Go on Google source are special cases and do not require VCS extensions.

  • version: Can be semantic version, semantic version range, branch, tag, or commit ID.

  • repo: If the package name is not repo location or this is a private repository, it can go here. The package will be checked out from repo and placed in the location specified by the package name. This allows the use of fork.

  • vcs: VCs to use, such as GIT,HG,BZR or SVN. Required only if the type cannot be detected from the name. For example, a repository that ends in. git or github can be detected as git. For BitBucket's repo, we can contact the API to discover the type.

  • subpackages: The record of the package that is used in the repository. This does not include all the packages in the repository, but rather includes the packages being used.

  • os: The list of operating systems used for filtering. If set it compares the current run-time operating system with the specified operating system, and only gets a matching dependency. If no filtering is set, the Skip is skipped. The names are the same as those used in the build flags and GOOS environment variables.

  • arch: A list of architectures for filtering. If set it compares the current run-time schema with the specified schema, and only gets the dependencies when matching. If no filtering is set, the Skip is skipped. GOARCHthe name is the same as the name used in the build flags and environment variables.

  • testImport: The list of packages used in tests that are not listed in the import. Each package has the same details as the import listed below.

Version and Range

Glide supports semantic versions,semver ranges,branches,tags and commit IDs as version.

Basic

A simple range format is > 1.2.3 . This tells Glide to use 1.2.3 the latest version after. It also supports the following operators:

    • =: Equals (can be omitted)

    • !=: Not equal to

    • >: Greater Than

    • <: Less than

    • >=: Greater than or equal to

    • <=: Less than or equal to

These can also be combined. ,Yes and and || yes or. Or operators can cause checks on groups and operators, such as: ">= 1.2, < 3.0.0 || >= 4.2.3" .

Hyphens-

There are several shortcuts to handle the range, the first is the hyphen range. These look like:

    • 1.2 - 1.4.5Equivalent to>= 1.2, <= 1.4.5

    • 2.3.4 - 4.5Equivalent to>= 2.3.4, <= 4.5

Wildcard charactersx,X,*

x, X and the * character can be used as a wildcard character. This applies to all comparison operators. When = used on an operator, it returns to the patch level comparison (see waveform below). For example:

    • 1.2.xEquivalent to>= 1.2.0, < 1.3.0

    • >= 1.2.xEquivalent to>= 1.2.0

    • <= 2.xEquivalent to< 3

    • *Equivalence and>= 0.0.0

Wave number ~ (Patch)

The waveform ( ~ ) comparison operator is used to specify the scope of the minor version modification, and the major level changes when the minor number is missing. For example:

    • ~1.2.3Equivalent to>= 1.2.3, < 1.3.0

    • ~1Equivalent to>= 1, < 2

    • ~2.3Equivalent to>= 2.3, < 2.4

    • ~1.2.xEquivalent to>= 1.2.0, < 1.3.0

    • ~1.xEquivalent to>= 1, < 2

Caret ^ (Major)

The caret ( ^ ) comparison operator is used for major level changes. This is useful when the API version comparison is broken as the major change is the API. For example:

    • ^1.2.3Equivalent to>= 1.2.3, < 2.0.0

    • ^1.2.xEquivalent to>= 1.2.0, < 2.0.0

    • ^2.3Equivalent to>= 2.3, < 3

    • ^2.xEquivalent to>= 2.0.0, < 3

This article link: https://deepzz.com/post/glide-package-management-introduce.html

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.