tools / godep

dependency tool for go
http://godoc.org/github.com/tools/godep
BSD 3-Clause "New" or "Revised" License
5.54k stars 455 forks source link

Git-ignoring the vendor/ directory #474

Closed calvn closed 8 years ago

calvn commented 8 years ago

I am not all too familiar with the inner-workings of dependency resolution for Go, so I wanted to know the reason behind the need to (git) include vendor/ in a Go project. If go restore would perform the vendoring before installing the packages in $GOPATH I think there would be no need to commit dependency sources into the project.

On npm, for instance, you would commit the package.json which has references (among other things) to all the dependencies that the package needs, but you don't commit node_pacakges which is what contains the source. npm install on the project would do the job of fetching all the dependencies. I was hoping for something similar on godep, which would make projects much lighter.

freeformz commented 8 years ago

When a repo is git pushed to remote that has no source, how will that remote build the source w/o hitting the network?

freeformz commented 8 years ago

If you are looking for that feature, please see govendor. PS: If you migrate to govendor, please don't use it's migrate command. I suggest instead doing:

$ godep restore
$ rm -rf Godeps vendor
$ govendor init
$ govendor add +ex
calvn commented 8 years ago

Your point is fair, but I think that git-ignoring vendor/ should be an option. godep restore should try to fetch remote dependencies if vendor/ is absent before showing failure due to network, if there is one. If vendor/ is already present, then simply skip that step. I think giving users the option is better than excluding it entirely.

Edit: I just dug deeper into this and saw #123 and #131 along with the proposal to remove such feature.

freeformz commented 8 years ago

@cleung2010 godep restore doesn't use the contents of vendor/ it's sole job is to fetch what is described in Godeps.json into $GOPATH.

calvn commented 8 years ago

I see. I was thinking maybe godep restore (or some alternate command) could do the fetching to vendor/. Anyhow, I think I've found glide, which has what I am looking for.

freeformz commented 8 years ago

@cleung2010 Great! FWIW: My recommendation would be govendor.