Qualified -src/-dst references; remove -external-pkg#3
Open
hacks1ash wants to merge 13 commits into
Open
Conversation
Walk up the directory tree from a given path to locate go.mod, then extract the module import path using golang.org/x/mod/modfile. On macOS, t.TempDir() returns /var/... symlink paths while filepath.EvalSymlinks resolves to /private/var/.... We intentionally skip EvalSymlinks so the returned moduleDir matches paths constructed from the same TempDir base, keeping test comparisons consistent.
…egeneration DiscoverMapperFuncs finds the previously-generated root function in the package, causing enqueue to treat it as already present and skip it entirely — producing an output file with only the package header. Delete the root (and reverse, when bidi) function names from the discovered set before passing it to GenerateMulti so only genuine nested-helper mappers are skipped on reuse.
…xample - Integrated `go:generate` directive to automate mapper generation. - Replaced manual mapping functions with generated equivalents. - Updated `.gitignore` to include generated docs and metadata files.
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
-external-pkgwith package-qualified-src/-dstvalues. Three forms supported:User) — current packagemodels.Userorinternal/models/request.RequestStruct) — joined to currentgo.modmodule rootgithub.com/org/repo/models.User) — loaded as-isGet<Field>()methods. New flags-getters(force) and-no-getters(disable) override the auto default.MatchCrossis gone;Match(src, dst, MatchOptions{...})is the single entry point. Bind tags work in both same- and cross-package mode.RunSamePackageandRunCrossPackagecollapse into a singlecli.Runthat selects the generator based on whether the resolved packages match._examples/02-protobuf-integrationand README/docs to the new syntax.Migration
Test plan
go test ./...passes (6 packages)_examples/01-standard-dto:go generate ./...regenerates byte-identical output to HEAD;go build ./...passes_examples/02-protobuf-integration: cross-package generation againstpb.Userproduces correct imports + bidi mappers; build passes after regen and after cleanupNotes
MatchOptions.DstGettersis plumbed but unused (reserved for a future writer-side feature).-external-pkg. Migration is one-line.