Go Dependency Management-govendor

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Golang official does not recommend the best package management solution. In the 1.5 release era, the official introduction of the package management design, added the vendor directory to support the local package management dependency. The official wiki recommends a variety of package management tools that support this feature, such as: GODEP, GV, GVT, Glide, Govendor, and more.

Here's a brief description of what I used in the project-- Govendor.
The tool copies the external packages that the project relies on to the vendor directory under the project, and records the version of the dependent package through the Vendor.json file, allowing users to use relatively stable dependencies.
For Govendor, there are several main types of dependency packages:

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

Installation

go get -u github.com/kardianos/govendor

Command line execution govendor , the installation succeeds if the following information is present.

➜  ~ govendorgovendor (v1.0.8): record dependencies and copy into vendor folder    -govendor-licenses    Show govendor's licenses.    -version              Show govendor version......

Warning: need to $GOPATH/bin/ add to PATH medium.

Quickstart

# Setup your project.cd "my project in GOPATH"# 初始化 vendor 目录, project 下出现 vendor 目录govendor init# Add existing GOPATH files to vendor.govendor add +external# View your work.govendor list# Look at what is using a packagegovendor list -v fmt# Specify a specific version or revision to fetchgovendor fetch golang.org/x/net/context@a4bbce9fcae005b22ae5443f6af064d80a6f5a55# Get latest v1.*.* tag or branch.govendor fetch golang.org/x/net/context@v1   # Get the tag or branch named "v1".govendor fetch golang.org/x/net/context@=v1  # Update a package to latest, given any prior version constraintgovendor fetch golang.org/x/net/context# Format your repository onlygovendor fmt +local# Build everything in your repository onlygovendor install +local# Test your repository onlygovendor test +local

Sub-commands

init     创建 vendor 文件夹和 vendor.json 文件list     列出已经存在的依赖包add      从 $GOPATH 中添加依赖包,会加到 vendor.jsonupdate   从 $GOPATH 升级依赖包remove   从 vendor 文件夹删除依赖status   列出本地丢失的、过期的和修改的packagefetch   从远端库增加新的,或者更新 vendor 文件中的依赖包sync     Pull packages into vendor folder from remote repository with revisionsmigrate  Move packages from a legacy tool to the vendor folder with metadata.get     类似 go get,但是会把依赖包拷贝到 vendor 目录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

Warning

    • The project must be within a $GOPATH/src .

    • If using go1.5, ensure you set GO15VENDOREXPERIMENT=1 .

Reference

Govendor GitHub
Go dependency Management-Govendor

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.