Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug when multiple interfaces were parsed #104

Merged
merged 1 commit into from
Jul 6, 2020

Conversation

anthonyraymond
Copy link
Contributor

@anthonyraymond anthonyraymond commented Jul 2, 2020

Fix #103

The loop was writing to a variable out of the scope and the second time it goes through if structName == "" { the condition was never false because the out of scope variable was updated with the first

It resulted in all generated interfaces being named the same (even if the implementation was distinct for each)

Fix petergtz#103 

The loop used to update an out-scopped variable on it's first iteration, and all the subsequent iteration failed to go into `if structName == "" {`.
The result was all the generated interface had the same name (even if the implementation was distinct for each)

The loop was writing to a variable out of the scope and the second time it goes through `if structName == "" {` the condition was never false because the out of scope variable was updated with the first
@petergtz
Copy link
Owner

petergtz commented Jul 3, 2020

Hey @anthonyraymond,

super cool that you've already fixed the issue you opened. I'm happy to merge it. Before I do that, what do you think, would you be able to also add a test for it? It's probably not super trivial, because all the tests so far simply use the one interface "Display" to do their testing. Adding another one might require a few more changes.

It looks to me like a new test could either go into mockgen_test.go or into main_test.go. The latter might be the simpler one and maybe for that one the changes are even limited to that file.

Curious to get your feedback.

Thanks,
Peter

@anthonyraymond
Copy link
Contributor Author

anthonyraymond commented Jul 3, 2020

HI @petergtz, thanks for your answer.

I was going to add a test in the first place, but i don't understood how to compile the project in the first place, so i had to break it appart to kind of adapt it the "module way", that was obviously not the good way to make this project module compliant ^^
Now i've deleted the "hacky" project and i'm kinda lazy to redo all of that.

But if you plan to officially migrate to module i'd be please to add a unit test for this

@petergtz
Copy link
Owner

petergtz commented Jul 6, 2020

Hey @anthonyraymond, sounds reasonable. I'll see if I can make some time to migrate it to modules sometime soon. For now, I'll merge it as is, but could you please change the pull request to go against develop instead of master (sorry, an issue template is also due).

@anthonyraymond anthonyraymond changed the base branch from master to develop July 6, 2020 20:34
@anthonyraymond
Copy link
Contributor Author

hi @petergtz , i've just changed the base branch for the PR 😉

@petergtz petergtz merged commit 81874f7 into petergtz:develop Jul 6, 2020
@petergtz
Copy link
Owner

petergtz commented Jul 6, 2020

I'll merge it to mainline and make a new release soon (once I have access to a computer again).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect type name generated in filemode with multiple interfaces
2 participants