Generate enum types with type-safe.
Requirements for the software and other tools to build, test and push
You can use the generator like this:
go get github.com/ervitis/gophenums
Then let's create a file with the types and constants. And add the comment associated to the type.
// gophenum:generate color
type color string
const (
Blue color = "blue"
Yellow color = "yellow"
Red color = "red"
)
Warning
The type and the name of the type in the comment has to be the same or it won't work
You can see some examples in the folder _examples
make tests
- Go1.21
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use Semantic Versioning for versioning. For the versions available, see the tags on this repository.
This project is licensed under the Apache 2.0