Skip to content

fix(go): resolve suffixed enum names through naming#3086

Merged
schani merged 1 commit into
masterfrom
fix/go-enum-type-name-suffix
Jul 24, 2026
Merged

fix(go): resolve suffixed enum names through naming#3086
schani merged 1 commit into
masterfrom
fix/go-enum-type-name-suffix

Conversation

@schani

@schani schani commented Jul 24, 2026

Copy link
Copy Markdown
Member

Description

Add an opt-in --enum-type-name-suffix Go renderer option, off by default, to make independently generated enums safe to combine in one package when their members overlap.

Unlike #3085, this derives each complete constant identifier with DependencyName during quicktype's naming pass instead of appending the enum name while emitting text. That lets the existing package-global namespace detect collisions involving the final identifier. For example, if BarkDogNoise is already a generated type, the naming pass can rename the enum constant rather than emit invalid Go with two BarkDogNoise declarations.

For #2624, enabling the option produces constants such as:

BarkDogNoise DogNoise = "BARK"
BarkTreePart TreePart = "BARK"

Tests

  • Added a unit regression covering:
    • default-off behavior
    • independently rendered enums with an overlapping BARK member
    • a collision between a qualified enum constant and a generated type
  • Added enum.schema to Go's quickTestRendererOptions with enum-type-name-suffix=true, so QUICKTEST generates and compiles qualified enum constants.

Commands run locally:

npm run build
npm run test:unit
npm run lint
QUICKTEST=true FIXTURE=schema-golang npm run test:fixtures -- test/inputs/schema/enum.schema

@github-actions

Copy link
Copy Markdown

Generated-output differences

1 files differ — 0 modified, 1 new, 0 deleted
187 changed lines — +187 / −0

Open the generated-output report →

@schani
schani merged commit 7b2fe4e into master Jul 24, 2026
30 checks passed
@schani
schani deleted the fix/go-enum-type-name-suffix branch July 24, 2026 16:38
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