Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cleanenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,16 @@ func parseValue(field reflect.Value, value, sep string, layout *string) error {

valueType := field.Type()

// Init struct for pointer
if valueType.Kind() == reflect.Ptr && field.IsNil() {
field.Set(reflect.New(valueType.Elem())) // Create the object
}

// Update the field if pointer
if field.Kind() == reflect.Ptr {
field = field.Elem()
}

// look for supported struct parser
// parsing of struct must be done before checking the implementation `encoding.TextUnmarshaler`
// standard struct types already have the implementation `encoding.TextUnmarshaler` (for example `time.Time`)
Expand Down