MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / parseEnumValue

Function parseEnumValue

env/parsers.go:28–37  ·  view source on GitHub ↗

parseEnumValue returns a parser function that looks up the input value in a map. The input value is trimmed before lookup. It assumes that m contains lowercase keys.

(m map[string]T)

Source from the content-addressed store, hash-verified

26// parseEnumValue returns a parser function that looks up the input value in a map.
27// The input value is trimmed before lookup. It assumes that m contains lowercase keys.
28func parseEnumValue[T any](m map[string]T) ParseFn[T] {
29 return func(env string) (T, error) {
30 var zero T
31 env = strings.ToLower(env)
32 if val, ok := m[env]; ok {
33 return val, nil
34 }
35 return zero, fmt.Errorf("invalid value %q", env)
36 }
37}
38
39// parseFloat parses the environment variable value as a 64-bit float.
40func parseFloat(env string) (float64, error) {

Callers 1

EnumFunction · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected