#79
The following is an example of what is currently generated:
// ParseFoo attempts to convert a string to a Foo
func ParseFoo(name string) (Foo, error) {
if x, ok := _FooValue[name]; ok {
return x, nil
}
return Foo(0), fmt.Errorf("%s is not a valid Foo", name)
}
To ease in a common use case of wanting to panic on an error, consider also generating (behind a flag -must?) the following:
// MustParseFoo attempts to convert a string to a Foo, panicking if unknown.
func MustParseFoo(name string) Foo {
x, err := ParseFoo(name)
if err != nil {
panic(err)
}
return x
}