{"repo":"dmarkham/enumer","free":true,"listed":false,"github":"https://github.com/dmarkham/enumer","clone":"git clone https://github.com/dmarkham/enumer.git","description":"A Go tool to auto generate methods for your enums","language":"Go","stars":522,"topics":["golang","enums","codegenerator","code-generation","codegeneration","enum","generator"],"license":null,"category":"dev-tools","readme_excerpt":"Enumer Enumer is a tool to generate Go code that adds useful methods to Go enums (constants with a specific type). It started as a fork of Rob Pike’s Stringer tool maintained by Álvaro López Espinosa. This was again forked here as (https://github.com/dmarkham/enumer) picking up where Álvaro left off. Generated functions and methods When Enumer is applied to a type, it will generate: - The following basic methods/functions: - Method String() : returns the string representation of the enum value. This makes the enum conform the Stringer interface, so whenever you print an enum value, you'll get the string name instead of a number. - Function String(s string) : returns the enum value from its string representation. This is useful when you need to read enum values from command line arguments, from a configuration file, or from a REST API request... In short, from those places where using the real enum value (an integer) would be almost meaningless or hard to trace or use by a human. s string is Case Insensitive. - Function Values() : returns a slice with all the values of the enum - Function Strings() : returns a slice with all the Strings of the enum - Method IsA () : returns true only if the current value is among the values of the enum. Useful for validations. - When the flag json is provided, two additional methods will be generated, MarshalJSON() and UnmarshalJSON() . These make the enum conform to the json.Marshaler and json.Unmarshaler interfaces. Very useful to use it in ","default_branch":null,"files":null,"tree":[],"storefront":"/r/dmarkham","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/dmarkham/enumer/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}