marcusolsson / goddd

Exploring DDD in Go
MIT License
2.41k stars 273 forks source link

Adopt a package management tool / makefile #16

Closed edoardo849 closed 8 years ago

edoardo849 commented 8 years ago

Hello! Participated at Goconf2016, awesome talk :-)
So I've forked this repo but run into trouble when trying to run it. Essentially the compiler first looks into the /vendor folder, but since in the code the imports are specified as github.com/marcusolsson/ it doesn't work when I clone the project in the local folder github.com/edoardo849.

My suggestion could be to use a package management tool like glide to fix the problems OR to specify in the README to create the folder GOPATH/src/github.com/marcusolsson and to git clone there.

Sample output:

./main.go:86: cannot use session (type *"github.com/edoardo849/goddd/vendor/gopkg.in/mgo.v2".Session) as type *"github.com/marcusolsson/goddd/vendor/gopkg.in/mgo.v2".Session in argument to mongo.NewCargoRepository
./main.go:87: cannot use session (type *"github.com/edoardo849/goddd/vendor/gopkg.in/mgo.v2".Session) as type *"github.com/marcusolsson/goddd/vendor/gopkg.in/mgo.v2".Session in argument to mongo.NewLocationRepository
./main.go:88: cannot use session (type *"github.com/edoardo849/goddd/vendor/gopkg.in/mgo.v2".Session) as type *"github.com/marcusolsson/goddd/vendor/gopkg.in/mgo.v2".Session in argument to mongo.NewVoyageRepository
./main.go:89: cannot use session (type *"github.com/edoardo849/goddd/vendor/gopkg.in/mgo.v2".Session) as type *"github.com/marcusolsson/goddd/vendor/gopkg.in/mgo.v2".Session in argument to mongo.NewHandlingEventRepository

I was also thinking that maybe it will be easier to just have a makefile to make run and make docker-run to do everything. If you agree I can create it myself and create a pull request. Let me know!

marcusolsson commented 8 years ago

Thank you, glad to hear you enjoyed it!

Yeah, that's something I need to add the the README. I'm currently using gvt for vendoring but that might subject to change. I haven't yet used glide myself but if you think it would improve the workflow then I'd be happy to accept a PR. Otherwise the alternative is, as you mentioned, to clone it into github.com/marcusolsson link.

Of course, I'd be happy to review a PR for a Makefile as well :)

peterbourgon commented 8 years ago

Glide won't fix this problem. Because this repo has a vendor directory, it is one (or multiple) Go binaries i.e. package mains. And in order to work with your own fork or copy of such a Go package, you need to work in the original repo's location on disk. That is,

  1. Make your fork in GitHub
  2. git clone git@github.com:original/repo
  3. cd repo
  4. git remote add yourname git@github.com:yourname/repo
  5. git checkout yourname
marcusolsson commented 8 years ago

I'll add the instructions to the README. Thanks for the input @peterbourgon!