MCPcopy Create free account
hub / github.com/opencloud-eu/opencloud / Decode

Function Decode

pkg/config/envdecode/envdecode.go:61–74  ·  view source on GitHub ↗

Decode environment variables into the provided target. The target must be a non-nil pointer to a struct. Fields in the struct must be exported, and tagged with an "env" struct tag with a value containing the name of the environment variable. An error is returned if there are no exported members t

(target any)

Source from the content-addressed store, hash-verified

59// url.Parse() function. Slices are supported for all above mentioned
60// primitive types. Semicolon is used as delimiter in environment variables.
61func Decode(target any) error {
62 nFields, err := decode(target, false)
63 if err != nil {
64 return err
65 }
66
67 // if we didn't do anything - the user probably did something
68 // wrong like leave all fields unexported.
69 if nFields == 0 {
70 return ErrNoTargetFieldsAreSet
71 }
72
73 return nil
74}
75
76// StrictDecode is similar to Decode except all fields will have an implicit
77// ",strict" on all fields.

Callers 15

ParseConfigFunction · 0.92
ParseConfigFunction · 0.92
ParseConfigFunction · 0.92
ParseConfigFunction · 0.92
ParseConfigFunction · 0.92
ParseConfigFunction · 0.92
ParseConfigFunction · 0.92
ParseConfigFunction · 0.92
ParseConfigFunction · 0.92
ParseConfigFunction · 0.92
ParseConfigFunction · 0.92
ParseConfigFunction · 0.92

Calls 1

decodeFunction · 0.85

Tested by 5

TestDecodeFunction · 0.68
TestDecodeErrorsFunction · 0.68
TestOnlyNestedFunction · 0.68
ExampleDecodeFunction · 0.68
TestExportFunction · 0.68