go-enum icon indicating copy to clipboard operation
go-enum copied to clipboard

Add support for case changing

Open ahobsonsayers opened this issue 3 years ago • 1 comments

The main reason behind this PR is I often have my enums defined as upper snake case like this: MY_ENUM. This means when I run the generator the constant generated is EnumTypeMYENUM, instead of EnumTypeMyEnum as expected.

Note: the lowercase name transformation is applied before the CamelCase transformation.

Example

Declaration:

// ENUM(MY_ENUM)
type EnumType int

Before this PR:

Generated Constant

const (
	// EnumTypeMYENUM is a EnumType of type MY_ENUM.
	EnumTypeMYENUM = iota
)

After this PR:

Generated Constant

const (
	// EnumTypeMyEnum is a EnumType of type MY_ENUM.
	EnumTypeMyEnum = iota
)

ahobsonsayers avatar Aug 24 '22 13:08 ahobsonsayers

Thanks for submitting a PR!

  1. please make this an opt in option rather than opt out. Changing default behavior is not something I want to do to current users.

  2. if you want to make sure that your PR passes in the tests, there is a make target of ci that you can use to run equivalent tests locally.

abice avatar Aug 24 '22 13:08 abice

Merged in an opt-in version of this functionality. Closing this PR

abice avatar Sep 15 '23 19:09 abice