mock icon indicating copy to clipboard operation
mock copied to clipboard

chore(model): delete reflect mode code

Open abhinav opened this issue 3 months ago • 4 comments

Alternative to #286

Reflect mode has been deprecated in favor of package mode. These functions, which were intended to be called from the generated code in reflect mode, are no longer needed.

Delete them.

abhinav avatar Oct 04 '25 23:10 abhinav

This change will break the existing code that does the model import. It will force to raise the major version.

tulzke avatar Oct 05 '25 07:10 tulzke

@tulzke are you using this? I’m curious what people are doing with this.

I ask because originally this was only used by the code generated in reflect mode, which doesn’t exist anymore.

But if someone is hand rolling their own reflect mode with this and the undocumented gob flag, this should probably be kept around and get some testing.

abhinav avatar Oct 05 '25 12:10 abhinav

@abhinav I'm talking about this. https://github.com/golang/mock/blob/main/README.md?plain=1#L275

The old code might have retained imports that do nothing today after replacing reflect with package mode. However, if you delete the package now, it will break backward compatibility when updating the dependency, since the import may have persisted. It seems like it's enough to just delete the import, but it's not obvious. This will raise obvious questions about why the package was deleted within the same major version.

I think it's just worth adding to the checklist of changes for the new major version.

tulzke avatar Oct 05 '25 13:10 tulzke

@tulzke this change doesn’t delete the package, only a couple functions from it. The placeholder import will continue to work.

abhinav avatar Oct 05 '25 15:10 abhinav