Dependency management in Golang
15/04/18 18:14 Filed in: Golang
Glide was one of the top tool for dependency management for Go. The Glide may become obsolete because of Dev packages introduced in Golang.
dep is a prototype dependency management tool for Go. It requires Go 1.9 or newer to compile. dep is safe for production use. Initially there was planning to integrate deployment into go 1.10.x version but still it has long way. So now you have to install and use separately.
Following are the examples for dep command.
dep init set up a new project
dep ensure install the project's dependencies
dep ensure -update update the locked versions of all dependencies
dep ensure -add github.com/pkg/errors add a dependency to the project
- Message from Glide team :
dep is a prototype dependency management tool for Go. It requires Go 1.9 or newer to compile. dep is safe for production use. Initially there was planning to integrate deployment into go 1.10.x version but still it has long way. So now you have to install and use separately.
Install dep package
- $ brew install dep
- $ brew upgrade dep
Create the project inside $GOPATH
- Create new project under $GOPATH/src/elasticcloudapps.com/hellodep
- package main
- import (
- )
- func main() {
- }
- Initialize dep
- Dep needs two files called Gopkg.lock and Gopkg.toml. You can initialize these files with following
- $ dep init
- Locking in master (d644981) for transitive dep golang.org/x/crypto
- Locking in master (2281fa9) for transitive dep golang.org/x/sys
- Using ^1.0.5 as constraint for direct dep github.com/sirupsen/logrus
- Locking in v1.0.5 (c155da1) for direct dep github.com/sirupsen/logrus
- After this the new files will be generated.
Following are the examples for dep command.
dep init set up a new project
dep ensure install the project's dependencies
dep ensure -update update the locked versions of all dependencies
dep ensure -add github.com/pkg/errors add a dependency to the project