Table of Contents
People coding in Golang is familiar with the ‘GOPATH’ the place where all your packages live.
package management in
go has been heavily opinionated and there has been many tools which attempted to solve this problem like glide,godep to name a few.
Now a tool called
dep has been surfacing the
go world for a while.Most
go projects are now moving to dep.Let’s talk about using dep. It’s very simple to get started with
dep.At root of your project, run this command
It takes a while to complete, because it is downloading all the project dependecies on to a directory called vendor in the directory where
init was called.If you wanna see the progress instead of waiting at a blank promt append the previos command with a
dep init -v
Now you will have two new files in root directory
dep is ready roll.From now on the only command you will probably need is
What this command essentialy do is update your dependecies. So how do you do that ?. Things are pretty simple, we do
import our dependencies the same old way in our
go source files, once we have done that do a
dep ensure that’s it!.There’s no manual bookkeeping to be done, your
Gopkg.toml will automatically be updated.
Now if you add a dependency more in the package manager way
dep got you covered :)
dep ensure -add github.com/foo/bar
To update dependecies run
dep ensure -update <package name> rightaway
If you wanna update all dependencies run a
dep ensure -update.
dep is an awesome tool and according to the official roadmap it will soon be added to the official golang toolchain.Refer the official dep docs for more.