How to Vendor Golang Dependencies with Docker — No git, GOPATH or godep required

Travis Reeder
Aug 6, 2015 · 2 min read
Image for post
Image for post

Update: took this a step further and made a Go tool for this.

Now you may be asking yourself “why in the hell would I want to do that?” Let me explain.

While writing the Go example for this post and the readme for this IronWorker, I kept finding myself trying to hack things together to make it easy for other people to just clone the repo and have it work. This is not as easy as it sounds with Go. Other languages are much easier to work with since they don’t force you to have a GOPATH or to have your code structured into particular directories inside that path. And to make matters worse, you have to install another tool like godep to vendor your dependencies and that has it’s own set of issues like forcing you to have your code in git. Anyways, it’s a royal PIA.

Docker to the Rescue

Vendor it

Build it

Run it

If you want to test this on something, here’s simple example you can clone (into any directory) and try it. Technical Blog

The place where we post all the good techie stuff.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store