ignore nil map values
This commit is contained in:
parent
cbf725a9ba
commit
f723bf0879
1 changed files with 4 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue