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├── README.md└── 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:
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