我正在使用 dep
来处理我的 Go 依赖项。将 vendor
目录也提交到版本控制中是最佳做法吗?还是在 checkout 存储库后始终执行 dep ensure
的最佳做法是?
最佳答案
dep
工具的常见问题解答 answers这个:
Should I commit my vendor directory?
It's up to you:
Pros
- It's the only way to get truly reproducible builds, as it guards against upstream renames, deletes and commit history overwrites.
- You don't need an extra
dep ensure
step to syncvendor/
withGopkg.lock
after most operations, such as go get, cloning, getting latest, merging, etc.Cons
- Your repo will be bigger, potentially a lot bigger, though prune can help minimize this problem.
- PR diffs will include changes for files under
vendor/
whenGopkg.lock
is modified, however files invendor/
are hidden by default on GitHub.
关于go - 提交 `vendor` 目录是最佳实践吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47346607/