github.com/s-urbaniak/glide@v0.0.0-20160527141859-5f5e941b1fc4/README.md (about)

     1  # Glide: Vendor Package Management for Golang
     2  
     3  ![glide logo](https://glide.sh/assets/logo-small.png)
     4  
     5  Are you used to tools such as Cargo, npm, Composer, Nuget, Pip, Maven, Bundler,
     6  or other modern package managers? If so, Glide is the comparable Go tool.
     7  
     8  *Manage your vendor and vendored packages with ease.* Glide is a tool for
     9  managing the `vendor` directory within a Go package. This feature, first
    10  introduced in Go 1.5, allows each package to have a `vendor` directory
    11  containing dependent packages for the project. These vendor packages can be
    12  installed by a tool (e.g. glide), similar to `go get` or they can be vendored and
    13  distributed with the package.
    14  
    15  [![Build Status](https://travis-ci.org/Masterminds/glide.svg)](https://travis-ci.org/Masterminds/glide) [![Go Report Card](http://goreportcard.com/badge/Masterminds/glide)](http://goreportcard.com/report/Masterminds/glide) [![GoDoc](https://godoc.org/github.com/Masterminds/glide?status.svg)](https://godoc.org/github.com/Masterminds/glide) [![Documentation Status](https://readthedocs.org/projects/glide/badge/?version=stable)](http://glide.readthedocs.org/en/stable/?badge=stable) [![Documentation Status](https://readthedocs.org/projects/glide/badge/?version=latest)](http://glide.readthedocs.org/en/latest/?badge=latest) [![Join the chat at https://gitter.im/Masterminds/glide](https://badges.gitter.im/Masterminds/glide.svg)](https://gitter.im/Masterminds/glide?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
    16  
    17  ### Features
    18  
    19  * Ease dependency management
    20  * Support **versioning packages** including [Semantic Versioning
    21    2.0.0](http://semver.org/) support. Any constraint the [`github.com/Masterminds/semver`](https://github.com/Masterminds/semver)
    22    package can parse can be used.
    23  * Support **aliasing packages** (e.g. for working with github forks)
    24  * Remove the need for munging import statements
    25  * Work with all of the `go` tools
    26  * Support the VCS tools that Go supports:
    27      - git
    28      - bzr
    29      - hg
    30      - svn
    31  * Support custom local and global plugins (see docs/plugins.md)
    32  * Repository caching including reuse of packages in the `$GOPATH`
    33  * Flatten dependencies resolving version differences and avoiding the inclusion
    34    of a package multiple times.
    35  * Manage and install dependencies on-demand or vendored in your version control
    36    system.
    37  
    38  ## How It Works
    39  
    40  The dependencies for a project are listed in a `glide.yaml` file. This can
    41  include a version, VCS, repository location (that can be different from the
    42  package name), etc. When `glide up` is run it downloads the packages (or updates)
    43  to the `vendor` directory. It then recursively walks through the downloaded
    44  packages looking for those with a `glide.yaml` file (or Godep, gb, gom, or GPM config
    45  file) that don't already have a `vendor` directory and installing their
    46  dependencies to their `vendor` directories. Once Glide has downloaded and figured
    47  out versions to use in the dependency tree it creates a `glide.lock` file
    48  containing the complete dependency tree pinned to specific versions. To install
    49  the correct versions use `glide install`.
    50  
    51  A projects is structured like this:
    52  
    53  ```
    54  - $GOPATH/src/myProject (Your project)
    55    |
    56    |-- glide.yaml
    57    |
    58    |-- glide.lock
    59    |
    60    |-- main.go (Your main go code can live here)
    61    |
    62    |-- mySubpackage (You can create your own subpackages, too)
    63    |    |
    64    |    |-- foo.go
    65    |
    66    |-- vendor
    67         |-- github.com
    68              |
    69              |-- Masterminds
    70                    |
    71                    |-- ... etc.
    72  ```
    73  
    74  *Take a look at [the Glide source code](http://github.com/Masterminds/glide)
    75  to see this philosophy in action.*
    76  
    77  ## Install
    78  
    79  On Mac OS X you can install the latest release via [Homebrew](https://github.com/Homebrew/homebrew):
    80  
    81  ```
    82  $ brew install glide
    83  ```
    84  
    85  On Ubuntu Precise(12.04), Trusty (14.04), Wily (15.10) or Xenial (16.04) you can install from our PPA:
    86  
    87  ```
    88  sudo add-apt-repository ppa:masterminds/glide && sudo apt-get update
    89  sudo apt-get install glide
    90  ```
    91  
    92  [Binary packages](https://github.com/Masterminds/glide/releases) are available for Mac, Linux and Windows.
    93  
    94  To build from source you can:
    95  
    96  1. Clone this repository into `$GOPATH/src/github.com/Masterminds/glide` and
    97     change directory into it
    98  2. Ensure that the environment variable GO15VENDOREXPERIMENT is set, for
    99     example by running `export GO15VENDOREXPERIMENT=1`
   100  3. Run `make build`
   101  
   102  This will leave you with `./glide`, which you can put in your `$PATH` if
   103  you'd like. (You can also take a look at `make install` to install for
   104  you.)
   105  
   106  The Glide repo has now been configured to use glide to
   107  manage itself, too.
   108  
   109  ## Usage
   110  
   111  ```
   112  $ glide create                            # Start a new workspace
   113  $ open glide.yaml                         # and edit away!
   114  $ glide get github.com/Masterminds/cookoo # Get a package and add to glide.yaml
   115  $ glide install                           # Install packages and dependencies
   116  # work, work, work
   117  $ go build                                # Go tools work normally
   118  $ glide up                                # Update to newest versions of the package
   119  ```
   120  
   121  Check out the `glide.yaml` in this directory, or examples in the `docs/`
   122  directory.
   123  
   124  ### glide create (aliased to init)
   125  
   126  Initialize a new workspace. Among other things, this creates a `glide.yaml` file
   127  while attempting to guess the packages and versions to put in it. For example,
   128  if your project is using Godep it will use the versions specified there. Glide
   129  is smart enough to scan your codebase and detect the imports being used whether
   130  they are specified with another package manager or not.
   131  
   132  ```
   133  $ glide create
   134  [INFO] Generating a YAML configuration file and guessing the dependencies
   135  [INFO] Attempting to import from other package managers (use --skip-import to skip)
   136  [INFO] Found reference to github.com/Sirupsen/logrus
   137  [INFO] Adding sub-package hooks/syslog to github.com/Sirupsen/logrus
   138  [INFO] Found reference to github.com/boltdb/bolt
   139  [INFO] Found reference to github.com/gorilla/websocket
   140  [INFO] Found reference to github.com/mndrix/ps
   141  [INFO] Found reference to github.com/spf13/cobra
   142  [INFO] Found reference to github.com/spf13/pflag
   143  [INFO] Found reference to github.com/tinylib/msgp/msgp
   144  [INFO] Found reference to github.com/unrolled/secure
   145  [INFO] Found reference to github.com/xeipuuv/gojsonschema
   146  [INFO] Found reference to github.com/zenazn/goji/graceful
   147  [INFO] Adding sub-package web to github.com/zenazn/goji
   148  [INFO] Adding sub-package web/mutil to github.com/zenazn/goji
   149  ```
   150  
   151  ### glide get [package name]
   152  
   153  You can download one or more packages to your `vendor` directory and have it added to your
   154  `glide.yaml` file with `glide get`.
   155  
   156  ```
   157  $ glide get github.com/Masterminds/cookoo
   158  ```
   159  
   160  When `glide get` is used it will introspect the listed package to resolve its
   161  dependencies including using Godep, GPM, Gom, and GB config files.
   162  
   163  ### glide update (aliased to up)
   164  
   165  Download or update all of the libraries listed in the `glide.yaml` file and put
   166  them in the `vendor` directory. It will also recursively walk through the
   167  dependency packages doing the same thing if no `vendor` directory exists.
   168  
   169  ```
   170  $ glide up
   171  ```
   172  
   173  This will recurse over the packages looking for other projects managed by Glide,
   174  Godep, gb, gom, and GPM. When one is found those packages will be installed as needed.
   175  
   176  A `glide.lock` file will be created or updated with the dependencies pinned to
   177  specific versions. For example, if in the `glide.yaml` file a version was
   178  specified as a range (e.g., `^1.2.3`) it will be set to a specific commit id in
   179  the `glide.lock` file. That allows for reproducible installs (see `glide install`).
   180  
   181  ### glide install
   182  
   183  When you want to install the specific versions from the `glide.lock` file use
   184  `glide install`.
   185  
   186  ```
   187  $ glide install
   188  ```
   189  
   190  This will read the `glide.lock` file and install the commit id specific versions
   191  there.
   192  
   193  When the `glide.lock` file doesn't tie to the `glide.yaml` file, such as there
   194  being a change, it will provide a warning. Running `glide up` will recreate the
   195  `glide.lock` file when updating the dependency tree.
   196  
   197  If no `glide.lock` file is present `glide install` will perform an `update` and
   198  generate a lock file.
   199  
   200  ## glide novendor (aliased to nv)
   201  
   202  When you run commands like `go test ./...` it will iterate over all the
   203  subdirectories including the `vendor` directory. When you are testing your
   204  application you may want to test your application files without running all the
   205  tests of your dependencies and their dependencies. This is where the `novendor`
   206  command comes in. It lists all of the directories except `vendor`.
   207  
   208      $ go test $(glide novendor)
   209  
   210  This will run `go test` over all directories of your project except the
   211  `vendor` directory.
   212  
   213  ## glide name
   214  
   215  When you're scripting with Glide there are occasions where you need to know
   216  the name of the package you're working on. `glide name` returns the name of the
   217  package listed in the `glide.yaml` file.
   218  
   219  ### glide rebuild
   220  
   221  Runs `go install` on the packages in the `glide.yaml` file. This
   222  (along with `glide install` and `glide update`) pays special attention
   223  to the contents of the `subpackages:` directive in the YAML file.
   224  
   225  ```
   226  $ glide rebuild
   227  [INFO] Building dependencies.
   228  [INFO] Running go build github.com/kylelemons/go-gypsy/yaml
   229  [INFO] Running go build github.com/Masterminds/cookoo/cli
   230  [INFO] Running go build github.com/Masterminds/cookoo
   231  ```
   232  
   233  This is useful when you are working with large 3rd party libraries. It
   234  will create the `.a` files, which can have a positive impact on your
   235  build times.
   236  
   237  **This feature is deprecated and will be removed before Glide 1.0.0**
   238  
   239  ### glide tree
   240  
   241  Glide includes a few commands that inspect code and give you details
   242  about what is imported. `glide tree` is one such command. Running it
   243  gives data like this:
   244  
   245  ```
   246  $ glide tree
   247  github.com/Masterminds/glide
   248  	github.com/Masterminds/cookoo   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/cookoo)
   249  		github.com/Masterminds/cookoo/io   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/cookoo/io)
   250  	github.com/Masterminds/glide/cmd   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/cmd)
   251  		github.com/Masterminds/cookoo   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/cookoo)
   252  			github.com/Masterminds/cookoo/io   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/cookoo/io)
   253  		github.com/Masterminds/glide/gb   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/gb)
   254  		github.com/Masterminds/glide/util   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/util)
   255  			github.com/Masterminds/vcs   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs)
   256  		github.com/Masterminds/glide/yaml   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/yaml)
   257  			github.com/Masterminds/glide/util   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/util)
   258  				github.com/Masterminds/vcs   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs)
   259  			github.com/Masterminds/vcs   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs)
   260  			gopkg.in/yaml.v2   (/Users/mfarina/Code/go/src/gopkg.in/yaml.v2)
   261  		github.com/Masterminds/semver   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/semver)
   262  		github.com/Masterminds/vcs   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs)
   263  		github.com/codegangsta/cli   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/codegangsta/cli)
   264  	github.com/codegangsta/cli   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/codegangsta/cli)
   265  	github.com/Masterminds/cookoo   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/cookoo)
   266  		github.com/Masterminds/cookoo/io   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/cookoo/io)
   267  	github.com/Masterminds/glide/gb   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/gb)
   268  	github.com/Masterminds/glide/util   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/util)
   269  		github.com/Masterminds/vcs   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs)
   270  	github.com/Masterminds/glide/yaml   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/yaml)
   271  		github.com/Masterminds/glide/util   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/util)
   272  			github.com/Masterminds/vcs   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs)
   273  		github.com/Masterminds/vcs   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs)
   274  		gopkg.in/yaml.v2   (/Users/mfarina/Code/go/src/gopkg.in/yaml.v2)
   275  	github.com/Masterminds/semver   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/semver)
   276  	github.com/Masterminds/vcs   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs)
   277  	github.com/codegangsta/cli   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/codegangsta/cli)
   278  ```
   279  
   280  This shows a tree of imports, excluding core libraries. Because
   281  vendoring makes it possible for the same package to live in multiple
   282  places, `glide tree` also prints the location of the package being
   283  imported.
   284  
   285  ### glide list
   286  
   287  Glide's `list` command shows an alphabetized list of all the packages
   288  that a project imports.
   289  
   290  ```
   291  $ glide list
   292  INSTALLED packages:
   293  	vendor/github.com/Masterminds/cookoo
   294  	vendor/github.com/Masterminds/cookoo/fmt
   295  	vendor/github.com/Masterminds/cookoo/io
   296  	vendor/github.com/Masterminds/cookoo/web
   297  	vendor/github.com/Masterminds/semver
   298  	vendor/github.com/Masterminds/vcs
   299  	vendor/github.com/codegangsta/cli
   300  	vendor/gopkg.in/yaml.v2
   301  ```
   302  
   303  ### glide help
   304  
   305  Print the glide help.
   306  
   307  ```
   308  $ glide help
   309  ```
   310  
   311  ### glide --version
   312  
   313  Print the version and exit.
   314  
   315  ```
   316  $ glide --version
   317  glide version 0.8.0
   318  ```
   319  
   320  ### glide.yaml
   321  
   322  The `glide.yaml` file does two critical things:
   323  
   324  1. It names the current package
   325  2. It declares external dependencies
   326  
   327  A brief `glide.yaml` file looks like this:
   328  
   329  ```yaml
   330  package: github.com/Masterminds/glide
   331  import:
   332    - package: github.com/Masterminds/semver
   333    - package: github.com/Masterminds/cookoo
   334      vcs: git
   335      version: ^1.2.0
   336      repo: git@github.com:Masterminds/cookoo.git
   337  ```
   338  
   339  The above tells `glide` that...
   340  
   341  1. This package is named `github.com/Masterminds/glide`
   342  2. That this package depends on two libraries.
   343  
   344  
   345  The first library exemplifies a minimal package import. It merely gives
   346  the fully qualified import path.
   347  
   348  When Glide reads the definition for the second library, it will get the repo
   349  from the source in `repo`, checkout the latest version between 1.2.0 and 2.0.0,
   350  and put it in `github.com/Masterminds/cookoo` in the `vendor` directory. (Note
   351  that `package` and `repo` can be completely different)
   352  
   353  **TIP:** The version is either VCS dependent and can be anything that can be checked
   354  out or a semantic version constraint that can be parsed by the [`github.com/
   355  Masterminds/semver`](https://github.com/Masterminds/semver) package.
   356  For example, with Git this can be a branch, tag, or hash. This varies and
   357  depends on what's supported in the VCS.
   358  
   359  **TIP:** In general, you are advised to use the *base package name* for
   360  importing a package, not a subpackage name. For example, use
   361  `github.com/kylelemons/go-gypsy` and not
   362  `github.com/kylelemons/go-gypsy/yaml`.
   363  
   364  ## Supported Version Control Systems
   365  
   366  The Git, SVN, Mercurial (Hg), and Bzr source control systems are supported. This
   367  happens through the [vcs package](https://github.com/masterminds/vcs).
   368  
   369  ## Frequently Asked Questions (F.A.Q.)
   370  
   371  #### Q: Why does Glide have the concept of sub-packages when Go doesn't?
   372  
   373  In Go every directory is a package. This works well when you have one repo
   374  containing all of your packages. When you have different packages in different
   375  VCS locations things become a bit more complicated. A project containing a
   376  collection of packages should be handled with the same information including
   377  the version. By grouping packages this way we are able to manage the related
   378  information.
   379  
   380  #### Q: bzr (or hg) is not working the way I expected. Why?
   381  
   382  These are works in progress, and may need some additional tuning. Please
   383  take a look at the [vcs package](https://github.com/masterminds/vcs). If you
   384  see a better way to handle it please let us know.
   385  
   386  #### Q: Should I check `vendor/` into version control?
   387  
   388  That's up to you. It's not necessary, but it may also cause you extra
   389  work and lots of extra space in your VCS. There may also be unforeseen errors
   390  ([see an example](https://github.com/mattfarina/golang-broken-vendor)).
   391  
   392  #### Q: How do I import settings from GPM, Godep, gom or gb?
   393  
   394  There are two parts to importing.
   395  
   396  1. If a package you import has configuration for GPM, Godep, gom or gb Glide will
   397     recursively install the dependencies automatically.
   398  2. If you would like to import configuration from GPM, Godep, gom or gb to Glide see
   399     the `glide import` command. For example, you can run `glide import godep` for
   400     Glide to detect the projects Godep configuration and generate a `glide.yaml`
   401     file for you.
   402  
   403  Each of these will merge your existing `glide.yaml` file with the
   404  dependencies it finds for those managers, and then emit the file as
   405  output. **It will not overwrite your glide.yaml file.**
   406  
   407  You can write it to file like this:
   408  
   409  ```
   410  $ glide import godep -f glide.yaml
   411  ```
   412  
   413  #### Q: Can Glide fetch a package based on OS or Arch?
   414  
   415  A: Yes. Using the `os` and `arch` fields on a `package`, you can specify
   416  which OSes and architectures the package should be fetched for. For
   417  example, the following package will only be fetched for 64-bit
   418  Darwin/OSX systems:
   419  
   420  ```yaml
   421  - package: some/package
   422    os:
   423      - darwin
   424    arch:
   425      - amd64
   426  ```
   427  
   428  The package will not be fetched for other architectures or OSes.
   429  
   430  ## LICENSE
   431  
   432  This package is made available under an MIT-style license. See
   433  LICENSE.txt.
   434  
   435  ## Thanks!
   436  
   437  We owe a huge debt of gratitude to the [GPM and
   438  GVP](https://github.com/pote/gpm) projects, which
   439  inspired many of the features of this package. If `glide` isn't the
   440  right Go project manager for you, check out those.
   441  
   442  The Composer (PHP), npm (JavaScript), and Bundler (Ruby) projects all
   443  inspired various aspects of this tool, as well.
   444  
   445  ## The Name
   446  
   447  Aside from being catchy, "glide" is a contraction of "Go Elide". The
   448  idea is to compress the tasks that normally take us lots of time into a
   449  just a few seconds.