使用Godep的多个项目的单个或多个路径

Currently I'm using godep for package vendoring for Go. The problem is that I'm working on multiple projects depending on different versions of a certain package. I can't decide how to structure my GOPATH(s). I have several options:

  • Use a single GOPATH and use godep restore when switching between projects. The different versions of the certain package will be switched.
  • Use a GOPATH per project and only use godep restore when needed.

Which option is recommended and why?

I'm working on multiple projects depending on different versions of a certain package

Then I would recommend a GOPATH per project, in order to better isolate each dependencies, and make sure there isn't any mix_up in said dependencies.

Within each GOPATH, you still can use the dependency manager of your choice.

I use that even with vendoring (just to be sure to get an independent workspace)

For vendoring, (Go 1.5+), I use govendor, typically:

govendor fetch +m

Pull in new dependencies or update existing dependencies directly from remotes with govendor fetch.

As a note, this has been obsolete since 1.5 and the advent of vendoring in Go.