Manage Go dependencies with govendor

This tutorial explains how to deploy a Go application which is using govendor to manage its dependencies. To handle the version management of the dependencies, please follow the offical govendor guide, this page will focus on the deployment of the app.

Configuration

During the deployment of a govendor-ed application, we’re looking at three special key in the configuration file vendor/vendor.json to give our deployment system the data we need to deploy correctly the application:

  • rootPath (String): The root package of your project, recent versions of govendor fills this field for you.

  • scalingo.goVersion (String): the major version of Go you would like Scalingo to use when compiling your code. If not specified, we’ll install the last stable version.

  • scalingo.install (Array of string): What should be installed of your application. We’ll default to ["."] to install the package at the top level of your project, if your executable is in the cmd directory, another common choice is ["./cmd/..."]. If you want to install all the packages including those which are vendored, you can use ["./..."].

Here is an example with https://github.com/Scalingo/sample-go-martini

{
  ...
  "rootPath": "github.com/Scalingo/sample-go-martini",
  "scalingo": {
    "install" : [ "." ],
    "goVersion": "go1.7.1"
  },
  ...
}

Ignored vendor/ sub directories

As specified in the govendor documentation, vendor/*/ can be added to your .gitignore file, excluding any vendored code from being included in git.

Scalingo runs govendor sync before running go install whenever govendor is detected. This is done to ensure that all dependencies specified in vendor.json are installed in your application’s vendor/ directory.

schedule 05 Oct 2016