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

Generating an interface in the same package as the implementation is broken #44

Open
stgraham2000 opened this issue Sep 23, 2023 · 0 comments

Comments

@stgraham2000
Copy link

Currently if you want to generate an interface file and have it reside in the same package as things the interface might depend on then you end up with generated code that fails to compile because the code is trying to import itself.

For instance, you have a package called car and you have defined a type car.Tire in the car package. You also have a service implementation file like car.Car and you have a method like ChangeTire(tire Tire). You now want to create an interface file in the same package car and call this interface file intf.go. If you try to generate the interface for car.Car you will have an extra import to the car package and your interface will have the method ChangeTire(tire car.Tire). This will fail to compile.

I expect the interface file to not have the extra import and the method should be ChangeTire(tire Tire).

stgraham2000 pushed a commit to Ioka-Technologies/interfaces that referenced this issue Sep 23, 2023
…ge as impl

Modify generator to detect if the dependency matches the new interface's
package name and if so, skip adding the dependency (so skip import).

Also, when generating the parameter package names, if the package matches
the new interface's package then make the package blank.
stgraham2000 pushed a commit to Ioka-Technologies/interfaces that referenced this issue Sep 23, 2023
…ge as impl

Modify generator to detect if the dependency matches the new interface's
package name and if so, skip adding the dependency (so skip import).

Also, when generating the parameter package names, if the package matches
the new interface's package then make the package blank.
stgraham2000 added a commit to Ioka-Technologies/interfaces that referenced this issue Sep 23, 2023
…_interface_in_same_package_as_impl

Fixes rjeczalik#44: Fix problem generating an interface in same package as impl
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

No branches or pull requests

1 participant