GODEP, Dependency tool for GO
Today I decided to start using Godep (dependency tool) to manage the versions of the packages I need in my Go projects. The idea is basic the same as Composer for PHP or package.json for Npm.
To run any of the following commands you need to have your GOBIN path set correctly. To verify this, please run go env. If there is a path on the GOBIN, check that is the correct one. If not, please add export GOBIN=correct_path to your .bashrc, .profile or .bash_profile
It seams really simple and ease to use.
You just need to install/update it:
go get -u github.com/tools/godep
And then you just have to go into your existing project and run:
godep save
If you get an error similar to this:
godep: Package (golang.org/x/sys/unix) not found
you need to install
go get -d golang.org/x/sys/unix
If all goes ok, the command will create a Godeps folder and a vendor folder. Inside of Godeps folder you will have a Godeps.json file that contains all packages with their current versions. Inside the vendor folder will be all the packages needed for your current app.
Just add the Godeps folder to your VCS, Git for example:
git add Godeps/ && git commit -m "Added Godeps vendor listing for better
dependency management"
Also don’t forget to add vendor folder to you .gitignore
When you need to get the packages (in case of deployment, or somebody else using ur app) you just need to use the command:
godep restore
For more information, visit the Godep github url at: https://github.com/tools/godep
Also this url (https://github.com/golang/go/wiki/PackageManagementTools) contains several other dependency management tools for Go.