For a long time, Golang has no good management of external dependencies and can only look for dependencies from the $GOPATH. This makes it possible for different users to install the same project that may be externally acquired to a different version of the dependent library, and cannot compile dependent missing items when the network is not available.
The Govendor tool has been introduced since version 1.5, which puts the project-dependent external packages under the vendor directory under the project (in contrast to the Node_modules directory of Nodejs) and records the version of the dependent package through the Vendor.json file, which makes it easier for users to use relatively stable The dependency.
For Govendor, there are three types of packages: The package is organized locally (local), the traditional dependency package for the $GOPATH is external (external) dependent package, and the Govendor-managed dependency package in the vendor directory is Vendor package.
Specifically, the possible types of these packages are as follows:
| Status |
abbreviation Status |
meaning |
| +local |
L |
Local package, which is the package organization of the project itself |
| +external |
E |
External package, which is managed $GOPATH, but not in the vendor directory |
| +vendor |
V |
has been managed by Govendor, i.e. in the vendor directory |
| +std |
S |
Packages in the standard library |
| +unused |
U |
Unused packages, which are wrapped in the vendor directory, but are not used by the project |
| +missing |
M |
The code references the dependent package, but the package does not find |
| +program |
P |
The main package, which means that you can compile to execute the file |
| +outside |
|
External packages and missing packages |
| +all |
|
All the Packages |
The common commands are the following, formatted as Govendor command.
By specifying the package type, you can filter operations only on the specified package.
remove dependencies from Vendor management
| command |
features |
| init |
Early Initialize Vendor directory |
| list |
list all dependent packages |
| Add |
Add package to Vendor directory such as Govendor add +external Add all external packages |
| Add pkg_path |
Add the specified dependency package to the vendor directory |
| update |
update the dependency package from the $GOPATH to the vendor directory |
| Remove |
| status |
list all missing, expired, and modified packages |
| fetch |
Add or update package to local vendor directory |
| sync |
Local presence Vendor.json pull dependency package, Match recorded version |
| get |
similar to go get directory, pull dependency package to Vendor directory |