Announcing Masterminds/vcs Package For Go

Working with varying version control systems (VCS) in Go can be difficult. For all commonalities between VCS there are notable differences. Because of the similarities it's possible to build an interface and common set of actions across different VCS.

The Go community has the package that's used by go get to work with varying systems. When we tried to use the vcs package as part of Glide we ran into difficulty. The vcs package is designed to work with the package management functions built into go get. It's not a general package and it's not easy to extend it to add new functionality. In Glide we wanted to build features other than those in go get.

The best solution we found was to build a new vcs package that implements what we needed. It's designed to provide a common interface to different VCS systems. We've tried to keep the application business logic out of it. That can be left up to packages that use the vcs package.

Quick Demo

To illustrate how this works the following is a quick demo that checks a codebase out to a local directory and sets the version to the 1.0.0 tagged release.

package main


func main() {
    // remote is the remote location for the VCS
    remote := ""

    // local is the directory to locally store the repo
    local, _ := ioutil.TempDir("", "go-vcs")

    // NewRepo will create a repo of the right type. It detects
    // the VCS from the URL and calls the appropriate VCS factory
    // such as NewGitRepo.
    repo, _ := NewRepo(remote, local)

    // Clone the repo to the local location.

    // Checkout version 1.0.0

VCS Support

The package currently supports Git, Mercurial (Hg), Bazaar (bzr), and Subversion (SVN). These are the same repo types supported by

Contributions and Feedback Welcome

While we use this package on Glide we hope it's useful for others. Contributions and feedback are welcome.