Dep is a dependency management tool, it helps in maintaining package dependencies and shipping the code with ease.

At first, dep must be initialized in the project root folder using dep init

# create project dir
$ mkdir /path/to/workspace_dir/swgapp
$ dep init

dep init will create two files “Gopkg.toml” and “Gopkg.lock” as seen below.

swgapp├── Gopkg.lock├── Gopkg.toml├──└── vendor

Gopkg.toml contains rules in a declarative fashion that will govern the behavior of dep. It allows project owners to specify dependency rules for required packages like its constraints, overrides, etc. Read more about it here.

Gopkg.lock is a transitively complete snapshot of the project’s dependency graph summarizing:

  • every package that project needs to compile
  • additional required packages
  • less any ignored packages

read more here

All resolved dependencies are downloaded in the vendor folder.

Use go env GOPATH to check the current GOPATH, it defaults to ‘$HOME/go’ if GOPATH is not set explicitly. To override the default path, follow the steps below to create and add your ‘workspace dir’ to GOPATH.

# create your workspace_dir and create 3 folders in it
$ mkdir /path/to/workspace_dir
# append below lines in ~/.profiles
export GOWSP=/path/to/workspace_dir

Aswad Rangnekar

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