增加每一项是否为interface类型的判断
This commit is contained in:
parent
bd989696a1
commit
2062e84b99
15
array.go
15
array.go
@ -56,3 +56,18 @@ func (at *ArrayType) IsValid() bool {
|
|||||||
}
|
}
|
||||||
return strings.HasPrefix(string(byteData), "[") && strings.HasSuffix(string(byteData), "]")
|
return strings.HasPrefix(string(byteData), "[") && strings.HasSuffix(string(byteData), "]")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ItemIsInterface 数组每一项是否为interface
|
||||||
|
//
|
||||||
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
|
//
|
||||||
|
// Date : 21:20 2023/6/11
|
||||||
|
func (at *ArrayType) ItemIsInterface() bool {
|
||||||
|
if !at.IsValid() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if _, ok := at.value.([]interface{}); ok {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestArray(t *testing.T) {
|
func TestArray(t *testing.T) {
|
||||||
val := []int64{1, 2, 3}
|
val := []interface{}{1, 2, 3}
|
||||||
fmt.Println(Array(val).IsValid())
|
fmt.Println(Array(val).IsValid())
|
||||||
|
fmt.Println(Array(val).ItemIsInterface())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user