Skip Navigation
Show nav
Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
Hide categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Troubleshooting Node.js Apps
      • Working with Node.js
      • Node.js Behavior in Heroku
    • Ruby
      • Rails Support
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • PHP Behavior in Heroku
      • Working with PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Vector Database
    • Working with AI
    • Heroku Inference
      • AI Models
      • Inference Essentials
      • Inference API
      • Quick Start Guides
    • Model Context Protocol
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Language Support
  • Go
  • Go Dependency Management
  • Go Dependencies via govendor

Go Dependencies via govendor

English — 日本語に切り替える

Last updated August 28, 2024

Table of Contents

  • Build configuration
  • Install or update govendor
  • Getting started
  • Adding dependencies
  • Dependency status
  • Updating an existing dependency
  • Removing unused dependencies

Govendor is no longer maintained. Govendor support on Heroku is deprecated and will be removed on March 1, 2025. Heroku suggests using Go Modules instead. If you have a govendor based application, please port it to Go modules ASAP.

This guide outlines how to fully use Heroku’s support for deploying Go applications that use govendor to manage the vendoring of dependencies.

The govendor FAQ covers the most common usage of the tool. We’ll cover the most common activities below.

Build configuration

When pushing code that uses govendor, Heroku will use several entries in the vendor/vendor.json file created by govendor to configure your build. These entries are:

  • rootPath (String): the root package name of the packages you are pushing to Heroku. You can find this locally with go list -e .. There is no default for this and it must be specified. Recent versions of govendor automatically fill in this field for you. You can re-run govendor init after upgrading to have this field filled in automatically, or it will be filled the next time you use govendor to modify a dependency.

  • heroku.goVersion (String): the major version of Go you would like Heroku to use when compiling your code. If not specified, Heroku defaults to the most recent supported version of Go.

  • heroku.install (Array of Strings): a list of the packages you want Heroku to install. If not specified, this defaults to ["."]. Other common choices are: ["./cmd/..."] (all packages and sub packages in the cmd directory) and ["./..."] (all packages and sub packages of the current directory). The exact choice depends on the layout of your repository. Please note that ./... includes any packages in your vendor directory.

  • heroku.sync (Boolean): By default Heroku runs govendor sync to ensure that the contents of vendor are what is specified in vendor.json. Sometimes there are reasons to not do this. Setting heroku.sync to false disables govendor sync.

Here is an example of these fields for a project using go1.6, located on your local machine at $GOPATH/src/github.com/heroku/go-getting-started and requiring a single package spec of ./... to install.

{
    ...
    "rootPath": "github.com/heroku/go-getting-started",
    "heroku": {
        "install" : [ "./..." ],
        "goVersion": "go1.6"
         },
    ...
}

You will need to use a text editor or a tool like jq to edit the vendor/vendor.json file if you need to configure the heroku.install or heroku.goVersion entries.

Ignored vendor/ sub directories

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

Heroku 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.

Install or update govendor

$ go get -u github.com/kardianos/govendor

That command downloads or updates the package containing the tool, placing the source code in $GOPATH/src/github.com/kardianos/govendor and then compiles the package, placing the govendor binary in $GOPATh/bin.

Getting started

  1. govendor init
  2. Inspect the changes with git diff (or similar).
  3. Commit the changes with git add -A vendor; git commit -am "Setup Vendor"

This creates a vendor/ directory and a vendor.json file in that directory.

Adding dependencies

  1. govendor fetch <package>
  2. Inspect the changes with git diff (or similar).
  3. Commit the changes with git add -A vendor; git commit -am "Add dependency <package>"

The package spec that govendor takes can also contain a version spec consisting of a tag or commit SHA of the specific revision of packages that you want to install to vendor/. For example, if you want to install v0.9.0 of the package github.com/Sirupsen/logrus you would run govendor fetch github.com/Sirupsen/logrus@v0.9.0. When a version spec is not supplied, the most recent commit is used.

Dependency status

$ govendor list
 v  github.com/gin-gonic/gin
 v  github.com/gin-gonic/gin/binding
 v  github.com/gin-gonic/gin/render
 v  github.com/manucorporat/sse
 v  github.com/mattn/go-colorable
 v  github.com/mattn/go-isatty
 v  golang.org/x/net/context
 v  gopkg.in/bluesuncorp/validator.v5
pl  github.com/heroku/go-getting-started/cmd/go-getting-started

This shows the different packages in use for the current project. See the govendor -h section named Status Types for a full description of what each letter means.

Updating an existing dependency

  1. govendor fetch <package>@<version>
  2. Inspect the changes with git diff (or similar).
  3. Commit the changes with git add -A vendor; git commit -m "Update <dependency>".

Just like when adding a new dependency, fetch can be used to update an existing dependency by fetching it and recording the update to vendor/vendor.json.

Removing unused dependencies

  1. govendor remove +u
  2. Inspect the changes with git diff (or similar).
  3. Commit the changes with git add -A vendor; git commit -m "Remove unused dependencies".

This removes all unused dependencies. You may want to check the output of govendor list +u first to see what govendor sees as being unused.

Keep reading

  • Go Dependency Management

Feedback

Log in to submit feedback.

Go Modules Go Modules

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices