https://github.com/golang/dep
https://golang.github.io/dep/
https://studygolang.com/articles/10589
安装
https://golang.github.io/dep/docs/installation.html
dep 帮助文档
root@jian-VirtualBox:~/git/zhonghangxun# dep help
Dep is a tool for managing dependencies for Go projects
Usage: "dep [command]"
Commands:
init Set up a new Go project, or migrate an existing one
status Report the status of the project's dependencies
ensure Ensure a dependency is safely vendored in the project
prune Pruning is now performed automatically by dep ensure.
version Show the dep version information
Examples:
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
Use "dep help [command]" for more information about a command.
root@jian-VirtualBox:~/git/zhonghangxun# dep help ensure
Usage: dep ensure [-update | -add] [-no-vendor | -vendor-only] [-dry-run] [-v] [<spec>...]
Project spec:
<import path>[:alt source URL][@<constraint>]
Ensure gets a project into a complete, reproducible, and likely compilable state:
* All non-stdlib imports are fulfilled
* All rules in Gopkg.toml are respected
* Gopkg.lock records precise versions for all dependencies
* vendor/ is populated according to Gopkg.lock
Ensure has fast techniques to determine that some of these steps may be
unnecessary. If that determination is made, ensure may skip some steps. Flags
may be passed to bypass these checks; -vendor-only will allow an out-of-date
Gopkg.lock to populate vendor/, and -no-vendor will update Gopkg.lock (if
needed), but never touch vendor/.
The effect of passing project spec arguments varies slightly depending on the
combination of flags that are passed.
Examples:
dep ensure Populate vendor from existing Gopkg.toml and Gopkg.lock
dep ensure -add github.com/pkg/foo Introduce a named dependency at its newest version
dep ensure -add github.com/pkg/foo@^1.0.1 Introduce a named dependency with a particular constraint
For more detailed usage examples, see dep ensure -examples.
Flags:
-add add new dependencies, or populate Gopkg.toml with constraints for existing dependencies (default: false)
-dry-run only report the changes that would be made (default: false)
-examples print detailed usage examples (default: false)
-no-vendor update Gopkg.lock (if needed), but do not update vendor/ (default: false)
-update update the named dependencies (or all, if none are named) in Gopkg.lock to the latest allowed by Gopkg.toml (default: false)
-v enable verbose logging (default: false)
-vendor-only populate vendor/ from Gopkg.lock without updating it first (default: false)
root@jian-VirtualBox:~/git/zhonghangxun# dep ensure -examples
dep ensure
Solve the project's dependency graph, and place all dependencies in the
vendor folder. If a dependency is in the lock file, use the version
specified there. Otherwise, use the most recent version that can satisfy the
constraints in the manifest file.
dep ensure -vendor-only
Write vendor/ from an existing Gopkg.lock file, without first verifying that
the lock is in sync with imports and Gopkg.toml. (This may be useful for
e.g. strategically layering a Docker images)
dep ensure -add github.com/pkg/foo github.com/pkg/foo/bar
Introduce one or more dependencies, at their newest version, ensuring that
specific packages are present in Gopkg.lock and vendor/. Also, append a
corresponding constraint to Gopkg.toml.
Note: packages introduced in this way will disappear on the next "dep
ensure" if an import statement is not added first.
dep ensure -add github.com/pkg/foo/subpkg@1.0.0 bitbucket.org/pkg/bar/baz@master
Append version constraints to Gopkg.toml for one or more packages, if no
such rules already exist.
If the named packages are not already imported, also ensure they are present
in Gopkg.lock and vendor/. As in the preceding example, packages introduced
in this way will disappear on the next "dep ensure" if an import statement
is not added first.
dep ensure -add github.com/pkg/foo:git.internal.com/alt/foo
Specify an alternate location to treat as the upstream source for a dependency.
dep ensure -update github.com/pkg/foo github.com/pkg/bar
Update a list of dependencies to the latest versions allowed by Gopkg.toml,
ignoring any versions recorded in Gopkg.lock. Write the results to
Gopkg.lock and vendor/.
dep ensure -update
Update all dependencies to the latest versions allowed by Gopkg.toml,
ignoring any versions recorded in Gopkg.lock. Update the lock file with any
changes. (NOTE: Not recommended. Updating one/some dependencies at a time is
preferred.)
dep ensure -update -no-vendor
As above, but only modify Gopkg.lock; leave vendor/ unchanged.
dep ensure -no-vendor -dry-run
This fails with a non zero exit code if Gopkg.lock is not up to date with
the Gopkg.toml or the project imports. It can be useful to run this during
CI to check if Gopkg.lock is up to date.