Skip to content

Commit

Permalink
Merge pull request #376 from jmorganca/mxyng/from-map-ignore-nil
Browse files Browse the repository at this point in the history
ignore nil map values
  • Loading branch information
mxyng committed Aug 17, 2023
2 parents cbf725a + f723bf0 commit c84bbf1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ func (opts *Options) FromMap(m map[string]interface{}) error {
if opt, ok := jsonOpts[key]; ok {
field := valueOpts.FieldByName(opt.Name)
if field.IsValid() && field.CanSet() {
if val == nil {
continue
}

switch field.Kind() {
case reflect.Int:
switch t := val.(type) {
Expand Down

0 comments on commit c84bbf1

Please sign in to comment.