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)
| 59 | // url.Parse() function. Slices are supported for all above mentioned |
| 60 | // primitive types. Semicolon is used as delimiter in environment variables. |
| 61 | func 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. |