Go Package Management gpm Introduction

Source: Internet
Author: User
Tags mercurial
This is a creation in Article, where the information may have evolved or changed. GPM is a minimalist package manager for Go leverages the power of the ' Go get ' command and the underlying version con Trol systems used by it-set your Go dependencies to desired versions, thus allowing easily reproducible builds in your Go projects. Go Package Manager makes no assumptions about your dependencies and supports Git, Bazaar and Mercurial hosted Go packages, For a smoother workflow is sure to check out [GVP] (HTTPS://GITHUB.COM/POTE/GVP)-The Go Versioning Packager which provid ES dependency isolation for your projects.

11-Line Installation GPM

wget https://raw.githubusercontent.com/pote/gpm/v1.4.0/bin/gpm --nochmod +x gpm && sudo mv gpm /usr/local/bin

2 The Godeps file

GPM expects to has a file called Godeps in the root of your Go application in the format

2.1 Packages

You can specify packages with the format, where version can is a revision number (a GIT/BAZAAR/MERCURIAL/SVN revision hash ) or a tag.

$ ls .Godeps  foo.go  foo_test.go$ cat Godepsgithub.com/nu7hatch/gotrail               v0.0.2github.com/replicon/fast-archiver         v1.02launchpad.net/gocheck                     r2013.03.03   # Bazaar repositories are supportedcode.google.com/p/go.example/hello/...    ae081cd1d6cc  # And so are Mercurial ones

Comments

The Godeps file accepts comments using a # symbol. Everything to the right of a # would be ignored by GPM, as well as empty lines.

Extensibility

As a convention comments can be used to specify lines the GPM core should ignore but is is instead intended to affect how a Given gpm plugin behaves.

For example:a hypothetical Gpm-track plugin, makes sure a given package was always updated to it last possible versio N would leverage a line like this one:

[gpm-track] github.com/nu7hatch/gotrail

This convention makes the godeps file format extensible, just as with plugins this can help identify common needs that MIG HT later on is merged into Core without have to sacrifice code simplicity in order to explore new features.

Private Repos

Both gpm and support go get using private GitHub repositories! Here's what's need to does in the order for a specific the is able to access them:

    • Generate a GitHub access token by following these instructions.
    • Add the following line to the ~/.netrc file in your home directory.
machine github.com login <token>

You can now use the GPM (and) to the go get install private repositories to which your user have access!:)

Completeness

It is recommended to keep a healthy and exhaustive file in the root of any Godeps Go project that use external dependencies , remember every package so you add to the Godeps file would be a installed along with it dependencies when GPM runs go get On it, so if you don't include these dependencies in your Godeps file is losing the ability to reproduce a build wit H 100% reliability.

Make sure your godeps file was exhaustive, this "any" project includes the documentation required to being built reliably at Any point in time.

Commands

GPM has the following commands:

$ gpm             # Same as 'install'.$ gpm get         # Parses the Godeps file, gets dependencies and sets them                  # to the appropriate version but does not install them.$ gpm install     # Parses the Godeps file, installs dependencies and sets                  # them to the appropriate version.$ gpm version     # Outputs version informationhelp        # Prints this message

Plugins

As of version v1.1.1 GPM supports plugins, the intent of which are the ability to add powerful Non-core features to gpm wit Hout compromising the simplicity of its codebase.

The-the-the-plugin works is simple:whenever a unknown command is passed into gpm it'll look for a executable in your $PATHcalled gpm-<command> and if it exists it would run it while passing all extra arguments to it, simple yet powerful.

This brings a IoT to the Table:plugins can is written in anything, they can be Go binaries, bash scripts, Ruby gems, Pyth On the packages, you name it. GPM wants to make it easy-to-extend it. :)

Installing plugins through Homebrew

I maintain a repository with homebrew formulae for gpm plugins so can add to your system with the brew tap command:

$ brew tap pote/gpm_plugins

After you've done this, the can install plugins as you would with any other homebrew packge.

$ brew install gpm-bootstrap

Known Plugins

If you had written a gpm plugin and want it included please send a pull request to the repo! I Love how people has taken to explore possible features using plugins so if you ' ve written one there are about a 99% chan Ce I'll include it here. :)

Short /tr> tr>
Name and Link AuthorDescription Type
gpm-bootstrap pote creates an initial godeps file official
gpm-git technosophos git management helpers third party
gpm-link elcuervo Dependency vendoring Third party
gpm-local technosophos Usage of local paths for packages third party
gpm-prebuild technosophos improves building performance third par Ty
gpm-all pote installs multiple sets of Deps official
gpm-lock zeeyang lock down dependency versions third PARTY

There is no real difference on Official/third party plugins other than the willingness of the GPM core team to support EAC H, plugins labeled as third party would be a supported (or not) by their authors.

Further Reading

The creator for the Gpm-git and Gpm-local wrote a fantastic blog post explaining the usage and rationale of GPM and GVP, I T sums up explanations for several of the design decisions behind both tools.

Contributing

Lots of people has contributed to make gpm what it's today, if you want to take your time to play around
With the Code so! Opening issues on Bugs, feature requests or simple food for thought is a great
The contribute, if you send a pull request, is a good citizen and do things in a tidy manner.

    • Create a feature branch with a meaningful name.
    • Make sure your commit messages and PR comments is informative.
    • Write a test for your feature if applicable.
    • Always remember to run the test suite with make test before comitting.

Either, thank you very much for all form of contribution, even if a patch ends up not being merged
The fact that it's sent and forced us to think about it's a contribution in itself.

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.