mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
fix: hide ZeroValue from dynamic
This commit is contained in:
parent
b66bcb1f67
commit
528d65c9fb
|
@ -47,19 +47,19 @@ func GetModifiableFields(val reflect.Value, callback func(tagName, name string))
|
|||
}
|
||||
}
|
||||
|
||||
var ZeroValue reflect.Value = reflect.Zero(reflect.TypeOf(0))
|
||||
var zeroValue reflect.Value = reflect.Zero(reflect.TypeOf(0))
|
||||
|
||||
func GetModifiableField(val reflect.Value, name string) (reflect.Value, bool) {
|
||||
field, ok := val.Type().FieldByName(name)
|
||||
if !ok {
|
||||
return ZeroValue, ok
|
||||
return zeroValue, ok
|
||||
}
|
||||
if field.Tag.Get("modifiable") != "true" {
|
||||
return ZeroValue, false
|
||||
return zeroValue, false
|
||||
}
|
||||
jsonTag := field.Tag.Get("json")
|
||||
if jsonTag == "" || jsonTag == "-" {
|
||||
return ZeroValue, false
|
||||
return zeroValue, false
|
||||
}
|
||||
return val.FieldByName(name), true
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user