interfaces icon indicating copy to clipboard operation
interfaces copied to clipboard

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

Open stgraham2000 opened this issue 1 year ago • 0 comments

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 avatar Sep 23 '23 01:09 stgraham2000