Skip to content

fix(deep-gen): stop emitting imports of internal/engine in generated code#44

Merged
brunoga merged 1 commit into
mainfrom
fix/deep-gen-internal-import
Jun 1, 2026
Merged

fix(deep-gen): stop emitting imports of internal/engine in generated code#44
brunoga merged 1 commit into
mainfrom
fix/deep-gen-internal-import

Conversation

@brunoga

@brunoga brunoga commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Expose deep.ApplyOpReflection as a public wrapper around the internal reflection fallback so generated *_deep.go files no longer need to import internal/engine — that import compiled in-tree but broke for any downstream user (Fixes Import internal deep package in the generated file #43).
  • Update the deep-gen template to call the public wrapper through the existing deep import; regenerate in-tree example and testmodel files to match.
  • Add TestGeneratedCodeHasNoInternalImports that runs the generator against internal/testmodels (which triggers the reflection fallback) and asserts no emitted import lives under github.com/brunoga/deep/v5/internal/....

Test plan

  • go build ./...
  • go vet ./...
  • go test ./...
  • Verified the new test fails when the internal import is reintroduced into the template, then passes after restoring the fix.

…code

Generated *_deep.go files previously imported
github.com/brunoga/deep/v5/internal/engine to call ApplyOpReflection as the
reflection fallback. That import is rejected by the Go compiler for any
package outside this module, so user code generated by deep-gen failed to
build.

Expose deep.ApplyOpReflection as a thin public wrapper around the engine's
internal function and update the generator template to call it via the
existing deep import. Regenerate the in-tree example and testmodel files
to match the new template output.

Add TestGeneratedCodeHasNoInternalImports to enforce the invariant: it
runs deep-gen against internal/testmodels (which exercises the reflection
fallback) and asserts no emitted import path lives under
github.com/brunoga/deep/v5/internal/.

Fixes #43.
@brunoga brunoga merged commit 9e5bffd into main Jun 1, 2026
1 check passed
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.

Import internal deep package in the generated file

1 participant