Skip to content

feat: Add Go language exporter using typed API struct literals (WIP)#104

Draft
MattDevy wants to merge 9 commits into
mainfrom
feat/go-converter
Draft

feat: Add Go language exporter using typed API struct literals (WIP)#104
MattDevy wants to merge 9 commits into
mainfrom
feat/go-converter

Conversation

@MattDevy

@MattDevy MattDevy commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

WIP

TODO:

  • Add esdsl support
  • Add many more test cases
  • Simplify and tidy-up code

Implements a TypeScript-based Go exporter that generates idiomatic
go-elasticsearch typed API code from Dev Console syntax. Uses the
bundled Elasticsearch spec metadata for type-aware struct literal
generation, including container variants, enums, dictionary types,
and shortcut properties.
Add a Go exporter that generates typed API struct literals for
go-elasticsearch/v9. Uses the expanded (no-generics) schema matching
what elastic-client-generator-go produces, with a type rename map for
naming collisions.

The exporter is structured as a modular subfolder (src/exporters/go/)
with focused, testable components: TypeResolver for schema lookups,
RenderContext for threading state through recursive rendering,
GoValueRenderer for value-to-Go-code conversion, and ImportTracker
for managing Go import statements.
Cover 19 additional test cases from the implementation plan: subclient
calls, enum query params, nested structures, aggregations, ingest
pipelines, KNN search, function score queries, runtime mappings, and
deeply nested queries.
- Resolve property aliases (JSON "aggs" → Go field "Aggregations")
- Remove incorrect id/ip special-casing in toPascalCase to match generator
- Resolve union type aliases to "any" when the Go type is a type alias
- Detect user_defined_value request bodies and render as untyped maps
- Track pointer vs value context in slices and map elements
- Ensure boolean query params render as bool, not string
- Route unknown container variant keys to AdditionalProperty map fields
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.

1 participant