fix(deep-gen): stop emitting imports of internal/engine in generated code#44
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
deep.ApplyOpReflectionas a public wrapper around the internal reflection fallback so generated*_deep.gofiles no longer need to importinternal/engine— that import compiled in-tree but broke for any downstream user (Fixes Import internal deep package in the generated file #43).deep-gentemplate to call the public wrapper through the existingdeepimport; regenerate in-tree example and testmodel files to match.TestGeneratedCodeHasNoInternalImportsthat runs the generator againstinternal/testmodels(which triggers the reflection fallback) and asserts no emitted import lives undergithub.com/brunoga/deep/v5/internal/....Test plan
go build ./...go vet ./...go test ./...