govendor usage

Why govendor

go dependency management is the most important language version control issues.
govendor is Golang dependencies management tool, it can avoid the emergence of different users get different versions of dependent libraries the problem from the outside after the clone the same project.
govendor project will require dependencies added to the project under the vendor directory, and the files are saved in the directory vendor.json path dependencies and other information added.
Golang project go look for a dependency file in order is to first look at the vendor, the vendor did not find then in the GOPATH in, did not find searched last in GOROOT in.
govendor only used to manage project dependencies, if the project does not have dependencies GOPATH, you need to first download go get GOPATH, and then by govendor add + external copied to the vendor directory.

Basic Usage

Installation govendor: go get -u github.com/kardianos/govendor
If you need to use the vendor's project had no vendor, you need to create vendor in the directory of the project
govendor init
later if you need to add dependencies, you can add two ways
govendor fetch path dependencies
govendor add path dependencies

.gitignore configuration:

/vendor/*
!/vendor/vendor.json

According vendor.json downloading dependencies: govendor sync

govendor usage examples:

cd path/to/project
govendor init
govendor fetch project_url_with_out_http
cat vendor/vendor.json

govendor commonly used commands

  • Increase package, add search, add and fetch get these two commands.
  • Update package, search update, will get the update and fetch these two commands.
  • Delete packages, search remove, get remove this command.
  • View already dependent packages, search list, get list, status, license orders, and is consistent with your list, and be able to know the status of packages listed expired.
➜  project_name git:(develop) govendor --help
govendor (v1.0.9): record dependencies and copy into vendor folder
    -govendor-licenses    Show govendor's licenses.
    -version              Show govendor version
    -cpuprofile 'file'    Writes a CPU profile to 'file' for debugging.
    -memprofile 'file'    Writes a heap profile to 'file' for debugging.

Sub-Commands

    init     Create the "vendor" folder and the "vendor.json" file.
    list     List and filter existing dependencies and packages.
    add      Add packages from $GOPATH.
    update   Update packages from $GOPATH.
    remove   Remove packages from the vendor folder.
    status   Lists any packages missing, out-of-date, or modified locally.
    fetch    Add new or update vendor folder packages from remote repository.
    sync     Pull packages into vendor folder from remote repository with revisions
                 from vendor.json file.
    migrate  Move packages from a legacy tool to the vendor folder with metadata.
    get      Like "go get" but copies dependencies into a "vendor" folder.
    license  List discovered licenses for the given status or import paths.
    shell    Run a "shell" to make multiple sub-commands more efficient for large
                 projects.

    go tool commands that are wrapped:
      "+status" package selection may be used with them
    fmt, build, install, clean, test, vet, generate, tool

Status Types

    +local    (l) packages in your project
    +external (e) referenced packages in GOPATH but not in current project
    +vendor   (v) packages in the vendor folder
    +std      (s) packages in the standard library

    +excluded (x) external packages explicitly excluded from vendoring
    +unused   (u) packages in the vendor folder, but unused
    +missing  (m) referenced packages but not found

    +program  (p) package is a main package

    +outside  +external +missing
    +all      +all packages

    Status can be referenced by their initial letters.

Package specifier
    <path>[::<origin>][{/...|/^}][@[<version-spec>]]

Ignoring files with build tags, or excluding packages from being vendored:
    The "vendor.json" file contains a string field named "ignore".
    It may contain a space separated list of build tags to ignore when
    listing and copying files.
    This list may also contain package prefixes (containing a "/", possibly
    as last character) to exclude when copying files in the vendor folder.
    If "foo/" appears in this field, then package "foo" and all its sub-packages
    ("foo/bar", …) will be excluded (but package "bar/foo" will not).
    By default the init command adds the "test" tag to the ignore list.

If using go1.5, ensure GO15VENDOREXPERIMENT=1 is set.
command Features
init Initialization vendor directory
list List all dependencies
add Vendor directory is added to the package, such as adding all govendor add + external outer cladding
add PKG_PATH added to the specified vendor directory dependencies
update From the $GOPATHupdate package to rely on vendor directory
remove Remove the dependency from vendor management
status List all missing, expired and modified package
fetch Add or update package to a local vendor directory
sync Local dependencies exist pull to match when the recorded version vendor.json
get Similar go get directory, to pull the vendor directory dependencies

Guess you like

Origin www.cnblogs.com/weiyinfu/p/10982848.html