使用vendor管理Golang项目依赖

本文详细介绍了Golang项目中使用govendor管理依赖的步骤和注意事项,包括设置项目、添加现有GOPATH文件到vendor、查看依赖、指定特定版本、更新包、格式化、构建、测试等操作。govendor支持多种版本控制系统,并强调了项目必须位于GOPATH内,且针对go1.5及更高版本的vendor特性。此外,文章还提到了govendor与其他包管理工具的差异和使用场景。
摘要由CSDN通过智能技术生成

The Vendor Tool for Go

go get -u github.com/kardianos/govendor

New users please read theFAQ

Package developers should read the developer guide.

For a high level overview read the whitepaper

Uses the go1.5+ vendor folder. Multiple workflows supported, single tool.

  • Copy existing dependencies from$GOPATH with govendor add/update .
  • If you ignore vendor/*/ , restore dependencies with govendor sync .
  • Pull in new dependencies or update existing dependencies directly from 
    remotes with govendor fetch .
  • Migrate from legacy systems with govendor migrate .
  • SupportsLinux, OS X, Windows, probably all others.
  • Supports git, hg, svn, bzr(must be installed an on the PATH).

Notes

  • The project must be within a $GOPATH.
  • If using go1.5, ensure you set GO15VENDOREXPERIMENT=1 .

Quick Start, also see theFAQ

Setup your project.

cd "my project in GOPATH"

govendor init

Add existing GOPATH files to vendor.

govendor add +external

View your work.

govendor list

Look at what is using a package

govendor list -v fmt

Specify a specific version or revision to fetch

govendor fetchgolang.org/x/net/context@a4bbce9fcae005b22ae5443f6af064d80a6f5a55

govendor fetch golang.org/x/net/context@v1 # Get latest v1. . tag or branch.

govendor fetch golang.org/x/net/context@=v1 # Get the tag or branch named "v1".

Update a package to latest, given any prior version constraint

govendor fetch golang.org/x/net/context

Format your repository only

govendor fmt +local

Build everything in your repository only

govendor install +local

Test your repository only

govendor test +local

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
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值