feat(common): public contracts package (v0.3.0 PR 2/10)#8
Merged
Conversation
Introduce pkg/common, the decoupling seam for the v0.3.0 refactor: - types: Target (loader-agnostic typed package), Finding, Layout, LayoutField, DiffStyle. - interfaces: Sizes (injectable arch sizing), Loader, Aligner, Inspector. These are the public contracts every internal package implements or consumes; kept out of internal/ so mockery can generate mocks from a non-internal source. Types and interfaces are mutually referential (Target<->Sizes, Loader<->Target), so they ship as one atomic, compilable commit. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Make DiffStyle a uint8 enum and let `go tool enumer` generate its String/parse/text-marshal helpers, matching the enumer convention used in go-httputil. Options: -text (MarshalText/UnmarshalText), -transform=lower and -trimprefix=Diff so the constants render as "unified"/"side"/"none". enumer v1.6.1 has no flag.Value generator, so a 3-line Set method delegates to the generated DiffStyleString parser, making *DiffStyle satisfy flag.Value for direct use with the flag package (wired in the future app package). Adds github.com/dmarkham/enumer as a tool dependency; diffstyle_enumer.go is committed (and auto-excluded from lint as generated code). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Upgrade enumer v1.6.1 -> v1.6.3 and add -flag.value to the generate directive so enumer emits the flag.Value Set method itself; drop the hand-written Set adapter. *DiffStyle still satisfies flag.Value (verified by the existing test), now fully generated — no bespoke code in pkg/common. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Second PR of the v0.3.0 refactor: the
pkg/commonpackage — the public contracts that decouple every layer. Pure declarations, no logic.What
types.go—Target(loader-agnostic view of a typed package, hidesgo/packages.Package),Finding,Layout,LayoutField,DiffStyle.interfaces.go—Sizes(injectable arch sizing; method set matchesgo/types.Sizesso it's directly assignable toanalysis.Pass.TypesSizes),Loader,Aligner,Inspector.Notes
pkg/common(notinternal/) so mockery can generate mocks from a non-internal source in a later PR.Target↔Sizes,Loader↔Target), so they ship as one atomic, compilable commit (no half-building intermediate).task cigreen.Part of the v0.3.0 package-refactor series.
🤖 Generated with Claude Code