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

Add transform to MACRO_CASE and phrase #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

abemedia
Copy link

Added support for transforming to MACRO_CASE and phrase.

1. phrase

We have a concrete use-case for phrase, which is using enumer to generate errors:

//go:generate enumer -type=ErrorCode -transform=phrase --trimprefix=Err

type ErrorCode int

func (e ErrorCode) Error() string {
	return e.String()
}

const (
	ErrInsufficientBalance ErrorCode = iota
	ErrInvalidNumberOfArguments
)

This means we can directly use these error constants as a normal error i.e.

ErrInvalidNumberOfArguments.Error() == "invalid number of arguments"

2. macro

MACRO_CASE as it's the most wide-spread form of defining constants (JS/Node, Ruby, Python, Bash) and makes sense for us as this is how we define them on our React front-end.

@abemedia
Copy link
Author

Shameless bump

@chickenandpork
Copy link

Shameless re-bump

@chickenandpork
Copy link

chickenandpork commented Oct 27, 2020

Is this met for you by @niktri's fork, Enumerx, release v1.1.5 ?

niktri@712e0f2

(transform=snake_upper)

@abemedia
Copy link
Author

To be honest I've been using my own fork that this PR is coming from: https://github.com/abeMedia/enumer
Would love to get this merged though!

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.

2 participants