Out of the box, Go provides just enough package management to make for a fast and efficient compiler. While it’s not opinionated enough to drive anyone away, Go package management doesn’t have the features to meet the needs of many developers. Especially for developers coming from PHP, Ruby, and node.js.
To add features, a number of developers have built package managers that sit on top of the core functionality. Since I’m working on glide I thought I do a light comparison to the others in this space. This is both to highlight where I think glide is strong and to share what’s happening in this space.
Glide is the brainchild of Matt Butcher. Glide handles both your workspace and dependent packages. To get into a shell with your
GOPATH set properly for a project it’s as simple as using the command
glide in. This will start a shell setup for you.
To handle packages:
- Start with a
glide.yamlfile. Being a YAML file you can define everything in readable format that supports comments.
- Document each package with it’s optional version. The version can be a branch, commit hash, or tag.
- Optionally, set an aliased repo. If you decide to fork a project but still need the include paths to work glide will take care of it for you.
glide installto install the packages into a
_vendorfolder is your
This saves you from vendoring while enabling you to choose specific versions. There are a number of supporting commands to help with this process.
GPM and GVP
With these packages you use a
Godeps file to specify the packages you want to use along with the version in the form of a hash or a tag.
There is a plugin system (glide has one too) that allows you to extend the base system. Interestingly, Matt Butcher (the creator of glide) wrote 3 of the 6 plugins currently available.
gom is another package manager and it’s configuration is stored in a
Gomfile has a simple custom format to specify packages and their version (tag, branch, or commit).
gom has a couple interesting features:
- Flags for development, test, and production. Some dependencies can only be installed in a particular environment.
- The ability to generate a
The packages are installed into a
While gom does a nice job handling packages it doesn’t help you with the
GOPATH in your current shell. This is something I’ve found to be incredibly useful in practice.
Godep is the package manager I’ve seen used the most. That’s in part because it’s been around for a year and a half. That’s an eternity in Go years.
With Godep the you can use the
godep save command to save dependencies to the file
Godeps/Godeps.json and the source to
godep restore will install the packages specified in the
Godeps/Godeps.json file to your
GOPATH. The version information Godep saves is the commit hash that’s currently in use. To add a dependency you use
go get to get the dependency and then use
godep save to update your stored configuration.
These are the package managers that caught my attention. If there’s another one in wide use I’m happy to look at it and add it to this list.
Given everything I’ve seen, which may not be everything, I’m a fan of glide. It has the features I use and goes far beyond what Go provides natively. Yet, I find it to be a useful feature set.