enumer/README.md

19 lines
590 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#Enumer
Enumer generates Go code to get string names from enum values and viceversa.
It is a fork of [Rob Pikes Stringer tool](https://godoc.org/golang.org/x/tools/cmd/stringer)
but adding a *"string to enum value"* method to the generated code.
For example, if we have an enum type called `Pill`, executing `enumer -type=Pill` will generate two methods:
```
func (i Pill) String() string {
//...
}
func PillString(s string) (Pill, error) {
//...
}
```
For more information on how to use, please go to the [Stringer docs](https://godoc.org/golang.org/x/tools/cmd/stringer)