Unverified Commit c84bbf1d authored by Michael Yang's avatar Michael Yang Committed by GitHub
Browse files

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

ignore nil map values
parents cbf725a9 f723bf08
...@@ -216,6 +216,10 @@ func (opts *Options) FromMap(m map[string]interface{}) error { ...@@ -216,6 +216,10 @@ func (opts *Options) FromMap(m map[string]interface{}) error {
if opt, ok := jsonOpts[key]; ok { if opt, ok := jsonOpts[key]; ok {
field := valueOpts.FieldByName(opt.Name) field := valueOpts.FieldByName(opt.Name)
if field.IsValid() && field.CanSet() { if field.IsValid() && field.CanSet() {
if val == nil {
continue
}
switch field.Kind() { switch field.Kind() {
case reflect.Int: case reflect.Int:
switch t := val.(type) { switch t := val.(type) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment