增加每一项是否为interface类型的判断

This commit is contained in:
白茶清欢 2023-06-11 21:22:08 +08:00
parent bd989696a1
commit 2062e84b99
2 changed files with 17 additions and 1 deletions

View File

@ -56,3 +56,18 @@ func (at *ArrayType) IsValid() bool {
}
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
}

View File

@ -13,6 +13,7 @@ import (
)
func TestArray(t *testing.T) {
val := []int64{1, 2, 3}
val := []interface{}{1, 2, 3}
fmt.Println(Array(val).IsValid())
fmt.Println(Array(val).ItemIsInterface())
}