Help us shape the future of Go! Take the 2026 Go Developer Survey

enum

package
v0.15.73 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package enum provides generic enum and bit-flag helpers (Go 1.18+ generics).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert[E Values](names []string) E

Convert returns enum value from names

func FlagNames

func FlagNames[E Names](val E) []string

FlagNames returns list of enum value names from flag value

func Flags

func Flags[E Names](val E) []E

FlagsInt returns list of enum values from flag

func FlagsInt

func FlagsInt[E Names](val E) []int32

FlagsInt returns list of enum values from flag

func NamesHelpString

func NamesHelpString(vals map[string]int32) string

NamesHelpString returns supported Enum values concatenated by ","

func Parse

func Parse[E Values](val string) E

Parse returns enum value from names

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 SliceNames[E Names](vals []E) []string

func SliceNamesString added in v0.15.73

func SliceNamesString[E Names](vals []E) string

func SupportedNames

func SupportedNames[E Values]() string

SupportedNames returns supported Enum values concatenated by ","

Types

type DisplayNames added in v0.15.73

type DisplayNames interface {
	Names
	DisplayNamesMap() map[int32]string
}

DisplayNames interface for enum with display names

type Enum

type Enum interface {
	~int32 | ~uint32
}

Enum interface for generic enum

type Names added in v0.9.48

type Names interface {
	Enum
	NamesMap() map[int32]string
}

Names interface for enum with names

type Values added in v0.9.48

type Values interface {
	Enum
	ValuesMap() map[string]int32
}

Values interface for enum with values

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL