MCPcopy Create free account
hub / github.com/abice/go-enum / ParseStatus

Function ParseStatus

example/negative_enum.go:122–131  ·  view source on GitHub ↗

ParseStatus attempts to convert a string to a Status.

(name string)

Source from the content-addressed store, hash-verified

120
121// ParseStatus attempts to convert a string to a Status.
122func ParseStatus(name string) (Status, error) {
123 if x, ok := _StatusValue[name]; ok {
124 return x, nil
125 }
126 // Case insensitive parse, do a separate lookup to prevent unnecessary cost of lowercasing a string if we don't need to.
127 if x, ok := _StatusValue[strings.ToLower(name)]; ok {
128 return x, nil
129 }
130 return Status(0), fmt.Errorf("%s is %w", name, ErrInvalidStatus)
131}

Callers 1

TestStatusStringFunction · 0.85

Calls 1

StatusTypeAlias · 0.85

Tested by 1

TestStatusStringFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…