Merge pull request #376 from jmorganca/mxyng/from-map-ignore-nil

ignore nil map values
This commit is contained in:
Michael Yang 2023-08-17 15:57:12 -07:00 committed by GitHub
commit c84bbf1dd6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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) {