You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用govendor实现类似go get ./...的批量依赖托管功能?

Solution for Vendorizing All Dependencies with Govendor

Great question! You're right that govendor get ./... doesn't behave the same way as go get ./..., but there are two straightforward ways to pull all your project's dependencies into the vendor directory in one go:

Method 1: Vendorize dependencies already in your GOPATH

If you've already run go get ./... to download dependencies to your local GOPATH, you can quickly copy them into the vendor folder:

  1. Initialize govendor in your project directory:
    govendor init
    
  2. Copy all external dependencies (everything not part of your project or the standard library) into vendor:
    govendor add +external
    

This command scans your project's imports, identifies all external packages already present in your GOPATH, and copies them into the vendor directory while updating vendor.json.

Method 2: Fetch dependencies directly into vendor (no pre-run go get)

If you haven't downloaded the dependencies yet, you can have govendor fetch them directly into the vendor folder:

  1. First initialize govendor:
    govendor init
    
  2. Fetch all missing dependencies (packages your project imports that aren't in vendor or your local project):
    govendor fetch +missing
    

This command will reach out to remote repositories, download all required dependencies, and place them straight into vendor—no need to clutter your GOPATH first.

Why govendor get ./... doesn't work

The govendor get command is designed to fetch specific packages and their dependencies, but it doesn't interpret the ./... wildcard the same way go get does. It won't recursively scan your project's imports to find all required dependencies, which is why it fails to replicate the behavior you're looking for.

To verify all dependencies are properly added, you can run:

govendor list

This will show all packages tracked by govendor, including those in the vendor directory.

内容的提问来源于stack exchange,提问作者SomeGuyFortune

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 09:23:32