Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it best-practice to commit the `vendor` directory?

Tags:

go

I am using dep to handle my Go dependencies. Is it best practice to also commit the vendor directory into version control? Or is best practice to always execute dep ensure after checking out a repository?

like image 490
Ztyx Avatar asked Nov 17 '17 08:11

Ztyx


People also ask

Should vendor folder commit?

The general recommendation is no. The vendor directory (or wherever your dependencies are installed) should be added to . gitignore / svn:ignore /etc. The best practice is to then have all the developers use Composer to install the dependencies.

What is vendor directory?

The vendor folder is where you usually (I'm using the word 'usually' because it's not exactly a rule but more of a preference in the coding community with the purpose of having a semantic directory structure) keep third-party resources(icons, images, codes, you name it) as opposed to a lib (library) folder where you or ...

What is vendor directory in go?

js land, Golang's vendor directory is basically the same as Node's node_modules . It is a directory found at the root of a Go module that stores a copy of all the code the module depends on. The vendored code is used to compile the final executable when the go build command is run.


1 Answers

The dep tool's FAQ answers this:

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 sync vendor/ with Gopkg.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/ when Gopkg.lock is modified, however files in vendor/ are hidden by default on GitHub.
like image 66
Ztyx Avatar answered Oct 20 '22 09:10

Ztyx