Fix value type

master v1.5.4
Stanly 1 month ago
parent b1fc83ab93
commit ba1e5f096f

@ -31,11 +31,9 @@ func (data Data) GetSlice(key string) (res Slice, err error) {
return nil, err
}
switch value := value.(type) {
switch v := value.(type) {
case []interface{}:
return value, nil
case Slice:
return value, nil
return v, nil
default:
return nil, ErrFormat
}
@ -125,11 +123,9 @@ func (data Data) GetData(key string) (Data, error) {
return nil, err
}
switch value := value.(type) {
switch v := value.(type) {
case map[string]interface{}:
return Data(value), nil
case Data:
return value, nil
return v, nil
default:
return nil, ErrFormat
}
@ -149,9 +145,9 @@ func (data Data) GetDataSlice(key string) ([]Data, error) {
}
var list []Data
for _, v := range values {
switch v := v.(type) {
case Data:
for _, value := range values {
switch v := value.(type) {
case map[string]interface{}:
list = append(list, v)
default:
return nil, ErrFormat

Loading…
Cancel
Save