matryer / moq

Interface mocking tool for go generate
http://bit.ly/meetmoq
MIT License
1.99k stars 126 forks source link

Handle import name collisions #127

Closed ibuildthecloud closed 3 years ago

ibuildthecloud commented 4 years ago

I fixed these issue before I looked to see if an existing PR was in the works, but I thought I'd submit this anyways. This should supercede #120 and #121.

Three cases are handled

  1. We maintain aliases from the source files. This is just a nicety and not really needed. This just makes the code prettier that is generated.
  2. Imports that conflict from multiple source files are handled.
  3. If the source file package conflict with an import. For example
    
    package foo

import "foo"

type Example interface { Bad() foo.Bar }


Using `-pkg bar` you would get a conflict on `foo.Bar` and `foo.Example`

Fixes #68
Fixes #94
ibuildthecloud commented 4 years ago

I realized that this PR would break #63 so I've update this PR to include #63 plus the small change to make it work. On the positive side this should be a faster approach and more reliable(?), maybe?

ibuildthecloud commented 4 years ago

So this should supercede #63 too. @sudo-suhas I'm sure you've busy but if you could review this PR it should close a lot of long standing issues.

ibuildthecloud commented 4 years ago

I don't know why travis-ci never goes green in GitHub, the build is passing https://travis-ci.org/github/matryer/moq/builds/707403162

andytsnowden commented 4 years ago

bump @sudo-suhas any chance you could review this sometime this week? This bug is blocking our usage of the great utility you've created.

ibuildthecloud commented 4 years ago

@sudo-suhas Pretty please look at this? I'd really like to continue to use moq, but not getting these things fixed upstream is just becoming too much. I'd rather not fork and am trying my best to do all the heavily lifting here. Please let me know if there is something I can do to help.

sudo-suhas commented 4 years ago

Hey @ibuildthecloud I completely understand and I had even taken a day off with the intention of resolving long standing issues. But I cannot merge any PRs until the Travis CI integration is fixed. I am not the owner so cannot make the necessary changes to the settings. I have requested @matryer's help to sort it out.

sudo-suhas commented 4 years ago

@ibuildthecloud could you rebase this PR? That should trigger the GitHub CI (the Travis CI issue has been resolved).

matryer commented 4 years ago

@ibuildthecloud thanks for your work on this.

aageneralov commented 3 years ago

What is the status of this PR? Its very useful feature

cgorenflo commented 3 years ago

@ibuildthecloud please rebase so this PR can be merged. I can't wait for this to become available :)

breml commented 3 years ago

@cgorenflo Please have a look at #141 and report if this resolves your issue as well.

cgorenflo commented 3 years ago

@breml Thanks for pointing that out, works like a charm!

damnedest commented 3 years ago

Is it possible to merge this to master?

matryer commented 3 years ago

This problem might be fixed now?

sudo-suhas commented 3 years ago

Yes, closed via #141.

matryer commented 3 years ago

Thanks to @ibuildthecloud for this contribution.