It already has been! Álvaro has done this for you. https://github.com/alvaroloes/enumer
This is a fork of stringer that has the function you want: - A function <Type>String(s string) to get 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. On Friday, February 10, 2017 at 1:35:57 AM UTC-6, tamal wrote: > > Hi, > We would like to be able to generate string to enum value method using > stringer in addition to String() method. > https://github.com/golang/tools/blob/master/cmd/stringer/stringer.go > > Is this something that can be added to Stringer? If yes, what is the > process for that? > > Thanks. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.