(p string)
| 25 | } |
| 26 | |
| 27 | func (a *Enum) Set(p string) error { |
| 28 | isIncluded := func(opts []string, val string) bool { |
| 29 | for _, opt := range opts { |
| 30 | if val == opt { |
| 31 | return true |
| 32 | } |
| 33 | } |
| 34 | return false |
| 35 | } |
| 36 | if !isIncluded(a.Allowed, p) { |
| 37 | return fmt.Errorf("%s is not included in %s", p, strings.Join(a.Allowed, ",")) |
| 38 | } |
| 39 | a.Value = p |
| 40 | return nil |
| 41 | } |
| 42 | |
| 43 | func (*Enum) Type() string { |
| 44 | return "string" |