tools / godep

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

Godep is removing nested Godeps #428

Open aanm opened 8 years ago

aanm commented 8 years ago

I'm importing a project that has a Godep directory.

foo
  - Godeps/

however it seems like godep is removing that directory (foo/Godeps) when I use godep save -r ./... in my own project, is this the expected behavior?

freeformz commented 8 years ago

Yes. It should flatten those deps out.

aanm commented 8 years ago

@freeformz But this is bad if 2 projects that I'm importing use 2 different version of a 3rd project. For example

foo
  - Godeps/a/v1
bar
  - Godeps/a/v2
freeformz commented 8 years ago

yes, we should do better there. There are also all sorts of problem related to v1 and v2 of "a" being used at the same time. For instance a type from v1 of "a" is not the same as the same type returned from v2 of "a". Even if they look the same. The only sane thing to do is flatten. We should ask / prompt / let the user decide which one to choose though (assuming we can't programmatically determine the best version).

aanm commented 8 years ago

But why can't godep store both Godeps in the final result?

final
  - Godeps/foo/Godeps/a/v1
  - Godeps/bar/Godeps/a/v2
 #and if final is directly using 'a', then also
  - Godeps/a
freeformz commented 8 years ago

Because there would then be 3 versions of the same dep. That can lead to confusing, unexpected and subtle errors in the program.

aanm commented 8 years ago

Why? foo will only use the deps inside its own Godeps/, bar would do the same and so on.

foo would have

import "github.com/foo/Godeps/a/v1"

bar would have

import "github.com/bar/Godeps/a/v2"
freeformz commented 8 years ago

if foo and bar happen to return their own a types to their users they won't be equal if compared, which can lead to issues. I don't have links handy but this has been discussed a bunch in Go issues and IIRC go-nuts.

aanm commented 8 years ago

Ah got it... Thanks for the explanation, yes it is difficult that way...