| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
Adds a new codegen utility to “flatten” Go API model structs into decode-efficient equivalents by replacing nested/complex field types with map[string]any, plus a cmd/flatten CLI wrapper for go:generate usage.
Changes:
Copilot reviewed 13 out of 13 changed files in this pull request and generated 8 comments.
Show a summary per file| File | Description |
|---|---|
| structs/flatten.go | Core generator: renders template, formats output, writes generated files, optional sorting. |
| structs/resolve.go | AST parsing helpers, JSON tag extraction, and type-flattening rules. |
| structs/options.go | Generator options (package name, header, scalar handling, sorting). |
| structs/templates/struct.go.tpl | Template for the generated flattened struct definition. |
| structs/testdata/input.go | Input models used by tests to validate flattening behavior. |
| structs/flatten_test.go | Snapshot tests validating output and edge cases/errors. |
| structs/.snapshots/* | Approved snapshots for generator output across scenarios. |
| cmd/flatten/main.go | CLI wrapper for running the generator via go run / go:generate. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
🤖 I have created a release *beep* *boop* --- ## [0.4.0](v0.3.37...v0.4.0) (2026-03-24) ### Features * Implement type flattener ([#419](#419)) ([de8ece6](de8ece6)) ### Bug Fixes * **deps:** Update dependency go to v1.26.0 ([#414](#414)) ([94c3c5f](94c3c5f)) * **deps:** Update golang.org/x/exp digest to 3dfff04 ([#412](#412)) ([28e9880](28e9880)) * **deps:** Update module github.com/cloudquery/plugin-sdk/v4 to v4.94.3 ([#410](#410)) ([144ce71](144ce71)) * **deps:** Update module github.com/cloudquery/plugin-sdk/v4 to v4.94.4 ([#415](#415)) ([35c026e](35c026e)) * **deps:** Update module github.com/cloudquery/plugin-sdk/v4 to v4.94.5 ([#416](#416)) ([4586c6d](4586c6d)) * **deps:** Update module github.com/cloudquery/plugin-sdk/v4 to v4.94.6 ([#417](#417)) ([16902da](16902da)) * **deps:** Update module github.com/cloudquery/plugin-sdk/v4 to v4.94.7 ([#418](#418)) ([71d532b](71d532b)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
| Back | FazBrowse Home | New Git URL |
Adds a structs package and cmd/flatten CLI to codegen that generates optimized Go structs from deeply nested API models. Nested struct fields are replaced with map[string]any to eliminate the decode -> allocate -> re-encode cycle when the SDK serializes them as JSON columns.
Usage:
//go:generate go run github.com/cloudquery/codegen/cmd/flatten -source=../api/models.go -from=Finding -to=flatFinding -output=finding_generated.go -package=services -sort
Options: -sort (ID first, then alphabetical), -extra (prepend fields like AssetType), -package (output package name).