/gophenums

enums in golang

Primary LanguageGoApache License 2.0Apache-2.0

Gophenums

Generate enum types with type-safe.

Getting Started

Prerequisites

Requirements for the software and other tools to build, test and push

Installing

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

Running the tests

make tests

Built With

  • Go1.21

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use Semantic Versioning for versioning. For the versions available, see the tags on this repository.

Authors

License

This project is licensed under the Apache 2.0