Skip to content

Instantly share code, notes, and snippets.

@ducc
Created October 14, 2016 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ducc/9e229c7e9e89a24e3efca1ea8fa757d0 to your computer and use it in GitHub Desktop.
Save ducc/9e229c7e9e89a24e3efca1ea8fa757d0 to your computer and use it in GitHub Desktop.
package main
import (
"reflect"
)
type MyEnum struct {
SOME_VALUE string
SOME_OTHER_THING string
}
func (enum MyEnum) values() []string {
val := reflect.Indirect(reflect.ValueOf(enum))
array := make([]string, val.NumField())
for i := 0; i < val.NumField(); i++ {
fVal := val.Field(i)
array[i] = fVal.String()
}
return array
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment