Documentation
¶
Overview ¶
Package enum provides generic enum and bit-flag helpers (Go 1.18+ generics).
Index ¶
- func Convert[E Values](names ...string) E
- func FlagNames[E Names](val E) []string
- func Flags[E Names](val E) []E
- func FlagsInt[E Names](val E) []int32
- func NamesHelpString(vals map[string]int32) string
- func Parse[E Values](val string) E
- func SliceDisplayNames[E DisplayNames](vals []E) []string
- func SliceDisplayNamesString[E DisplayNames](vals []E) string
- func SliceNames[E Names](vals []E) []string
- func SliceNamesString[E Names](vals []E) string
- func SupportedNames[E Values]() string
- type DisplayNames
- type Enum
- type Names
- type ProtoEnum
- type Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Convert ¶
Convert returns enum value from names. If multiple names are provided, the enum value is the bitwise OR of the values.
func NamesHelpString ¶
NamesHelpString returns supported Enum values concatenated by ","
func SliceDisplayNames ¶ added in v0.15.73
func SliceDisplayNames[E DisplayNames](vals []E) []string
func SliceDisplayNamesString ¶ added in v0.15.73
func SliceDisplayNamesString[E DisplayNames](vals []E) string
func SliceNames ¶ added in v0.15.73
func SliceNamesString ¶ added in v0.15.73
func SupportedNames ¶
SupportedNames returns supported Enum values concatenated by ","
Types ¶
type DisplayNames ¶ added in v0.15.73
type DisplayNames interface {
Names
// DisplayNamesMap returns a map of enum values to their display names
DisplayNamesMap() map[int32]string
}
DisplayNames interface for enum with display names
type Names ¶ added in v0.9.48
type Names interface {
Enum
// NamesMap returns a map of enum values to their names
NamesMap() map[int32]string
}
Names interface for enum with names
type ProtoEnum ¶ added in v0.15.77
type ProtoEnum interface {
String() string
Descriptor() protoreflect.EnumDescriptor
Number() protoreflect.EnumNumber
}
Click to show internal directories.
Click to hide internal directories.