Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(go): --enum-type-name-suffix to avoid same-package enum conflicts #2625

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export class GoRenderer extends ConvenienceRenderer {
let columns: Sourcelike[][] = [];
this.forEachEnumCase(e, "none", (name, jsonName) => {
columns.push([
[name, " "],
this._options.enumTypeNameSuffix ? [name, enumName, " "] : [name, " "],
[enumName, ' = "', stringEscape(jsonName), '"']
]);
});
Expand Down
6 changes: 4 additions & 2 deletions packages/quicktype-core/src/language/Golang/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export const goOptions = {
"omit-empty",
'If set, all non-required objects will be tagged with ",omitempty"',
false
)
),
enumTypeNameSuffix: new BooleanOption("enum-type-name-suffix", "Appends the type name to enum contracts", false)
};

export class GoTargetLanguage extends TargetLanguage {
Expand All @@ -32,7 +33,8 @@ export class GoTargetLanguage extends TargetLanguage {
goOptions.packageName,
goOptions.multiFileOutput,
goOptions.fieldTags,
goOptions.omitEmpty
goOptions.omitEmpty,
goOptions.enumTypeNameSuffix
];
}

Expand Down