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
      • Working with PHP
      • PHP Behavior in Heroku
    • 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
    • Working with AI
    • Heroku Inference
      • Inference API
      • Quick Start Guides
      • Inference Essentials
      • AI Models
    • Vector Database
    • 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 Godep

Go Dependencies via Godep

English — 日本語に切り替える

Last updated August 28, 2024

Table of Contents

  • Using godep
  • Adding new dependencies
  • Updating an existing dependency
  • Changing the version of Go used to build your application
  • Migrating from Godep workspace to go1.6 with a vendor/ directory

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

This guide outlines how to fully utilize Heroku’s support for specifying dependencies for your Go application with godep.

Godep is a tool that vendors your application’s dependencies into its source repository thereby enabling repeatable builds and reducing external build dependencies.

Using godep

Install/update godep:

$ go get -u github.com/tools/godep

To have godep determine, save and rewrite your application’s dependencies, navigate to your application’s directory within $GOPATH and run the following command:

$ godep save ./...

This will have the following effects:

  1. A Godeps/Godeps.json file will be created that contains the JSON representation of the application’s dependencies, the packages that we’re working on (the package spec) and the version of Go you are using locally.
  2. Each dependency will be copied into a subdirectory of vendor/.

These changes need to be committed to your application’s git repository like so:

$ git add -A .
$ git commit -m "Vendoring dependencies"

The Godeps/Godeps.json file is used by Heroku’s Go buildpack to determine the version of Go to use when compiling the application. Because of this you should run godep save ./... on your application even if it doesn’t have any external dependencies.

Adding new dependencies

  1. go get the new dependency.
  2. Edit your application’s source code to import the new dependency.
  3. Run godep save ./... to update Godeps/Godeps.json and copy the dependencies source to vendor/.

Updating an existing dependency

  1. go get -u <dependency>.
  2. godep update <dependency>.
  3. Inspect the changes with git diff (or similar).
  4. Commit the changes with git add -A .; git commit -m "Update <dependency>".

Changing the version of Go used to build your application

The major version of the Go toolchain is recorded in the Godeps/Godeps.json file in the GoVersion key and begins with go.

{
  "ImportPath": "github.com/heroku/go-getting-started",
  "GoVersion": "go1.6",
...
}

You can change the version in one of two ways:

  1. Installing and using a new major go version locally and then running godep update -goversion. This adjusts Godeps/Godeps.json files based on the version of go you are using.

  2. Manually changing the value of GoVersion in Godeps/Godeps.json to a valid major Go version (see go version).

Then committing the changes and pushing the app to Heroku will recompile the application with the current version of the newly specified major go version.

Specifying a specific minor version of Go

Godep records only the major version of the go toolchain (eg: go1.6 instead of go1.6.2). One each push Heroku will use the latest supported minor version of the toolchain to compile your application. This is our recommended setup. If however, you require a specific minor revision, this can be accomplished by specifying the full minor version in the GoVersion field of the Godeps/Godeps.json file.

Using a development version of Go

If you require a development version of Go, you can set the GoVersion field of the Godeps/Godeps.json file to devel-<short sha>. The <short-sha> should be replaced with the short git sha of the commit Heroku should use. On the next push, Heroku will retrieve that revision of Go from Github and compile it, using that version to build your application.

Migrating from Godep workspace to go1.6 with a vendor/ directory

  • Make sure you are using go1.6 (go version).
  • Make sure you have the latest godep (go get -u github.com/tools/godep)
  • godep restore, to ensure the project’s dependencies are “restored” to your $GOPATH.
  • If you are using rewrites run godep save -r=false <pkg spec> to remove them.
  • rm -rf Godeps to remove old dependency info.
  • godep save <pkg spec> to re-save the deps to vendor/.
  • git add -A; git commit -am "Upgrade to go1.6" to commit the changes to the repo.
  • git push heroku master to deploy using go1.6 and a vendor/ directory.

If you run into any problems please file a support ticket. Output from the above steps would be most helpful when troubleshooting.

Keep reading

  • Go Dependency Management

Feedback

Log in to submit feedback.

Go Modules Go Dependencies via govendor

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