Skip to content

Pass SourcePackageInstance to gowrap generator to avoid redundant package load#158

Open
jerenkrantz wants to merge 1 commit intogojuno:masterfrom
jerenkrantz:jerenkrantz/pass-source-package-instance
Open

Pass SourcePackageInstance to gowrap generator to avoid redundant package load#158
jerenkrantz wants to merge 1 commit intogojuno:masterfrom
jerenkrantz:jerenkrantz/pass-source-package-instance

Conversation

@jerenkrantz
Copy link

Summary

  • gowrap's generator.Options has a SourcePackageInstance field that accepts
    a pre-loaded *packages.Package, skipping the redundant pkg.Load() call
    inside NewGenerator()
  • minimock already loads the source package in run() but wasn't passing it
    through, causing gowrap to load it again for every interface
  • This is a one-line addition with no behavioral change

Motivation

Each pkg.Load() call spawns a go list subprocess. For projects generating
many mocks, eliminating this redundant load per interface reduces wall time
by ~35% in testing.

This PR description was written by Claude Code, not a human.

🤖 Generated with Claude Code

…kage load

gowrap's generator.Options already supports a SourcePackageInstance field
to accept a pre-loaded *packages.Package, but minimock was not using it.
This caused NewGenerator() to call pkg.Load() a second time for the same
source package on every interface, spawning a redundant go list subprocess
each time.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant