Go Vendor Introduction

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed. Go vendor is the way that the Go 1.5 official Introduction Management Pack relies, 1.6 formally introduced


The basic idea is that the source code of the referenced external package is placed under the current project's vendor directory, go 1.6 after the compilation of Go code will take precedence from the vendor directory first to find a dependency package;


1. The problem solved:
Copy the source code to the current project's vendor directory, so that the current project code to the $GOPATH/SRC of any machine can be compiled to avoid excessive external dependencies of the project code, after the migration,
Multiple go-get outsourcing dependencies are required, and the version of the external dependency package that is re-pulled through go get may be inconsistent with the project development, resulting in a compilation error.




2. Unresolved issues:
It is not possible to accurately reference the external package for versioning, you cannot specify an external package that references a particular version, but you copy it at development time, but once the external package is upgraded, the code under vendor does not follow the upgrade.
and vendor below does not have the meta file to record the version information of the reference package, this reference to the external package upgrade has a great problem, unable to assess the risks of the upgrade;


3. Resolve the unresolved issues with go vendor using Govendor, which has the following benefits:
Https://github.com/kardianos/govendor
1> You can smoothly convert an existing non-vendor project to a vendor project
Govendor Add Inport_out_packagename
2> generates a metadata file that records the external packages that the project relies on, as well as its version information
Vendor/vendor.json
3> provides commands to view the dependencies of the entire project
Goverdor--list

Goverdor--list-v


Project
Https://github.com/kardianos/govendor


Sub-commands


Init Create the "Vendor" folder and the "Vendor.json" file. #创建一个vendor目录并生成个空的verdor. json file
List List and filter existing dependencies and packages. #查看已经存在的依赖包
Add add packages from $GOPATH. Copy the package from the #把 $GOPATH to the vendor directory
Update update packages from $GOPATH. Packages in the #把 $GOPATH are updated to the vendor directory
Remove remove packages from the Vendor folder. #从vendor目录下移除外部依赖包
Status Lists any packages missing, out-of-date, or modified locally. #查看缺失的或者本地修改的包
Fetch ADD New or update vendor folder packages from remote repository. #从远程代码库拉取依赖包到vendor目录
Sync pull packages to Vendor folder from remote repository with revisions #一句本地vendor/verdor.json file specifies the package machine version information pulled from the repository Fetch Resources
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. #等于go Get but synchronize external dependency packages to the vendor directory instead of $GOPATH/SRC
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 is wrapped:
' +<status> ' package selection is used with them
FMT, build, install, clean, test, vet, generate, tool


Status


Packages can specified by their "status".


+local (l) packages in your project
+external (e) referenced packages in Gopath and not in current project
+vendor (v) packages in the Vendor folder
+STD (s) packages in the library


+excluded (x) external packages explicitely excluded from vendoring
+unused (U) packages in the Vendor folder, but unused
+missing (m) referenced packages but not found


+program (P) package was a main package


+outside +external +missing
+all +all Packages

Related Article

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.