完善convert方法

This commit is contained in:
白茶清欢 2023-06-26 18:08:18 +08:00
parent e11c833562
commit 1ca4b993fb

View File

@ -86,16 +86,16 @@ func (at *ArrayType) ItemIsInterface() bool {
// Author : go_developer@163.com<白茶清欢>
//
// Date : 17:59 2023/6/12
func (at *ArrayType) Convert() {
func (at *ArrayType) Convert() ([]interface{}, error) {
if at.IsNil() {
// 空指针
at.convertResult = make([]interface{}, 0)
return
return at.convertResult, nil
}
if !at.IsValid() {
// 无效slice
at.convertErr = errors.New("input slice is invalid")
return
return nil, at.convertErr
}
switch val := at.value.(type) {
case []int8:
@ -204,6 +204,17 @@ func (at *ArrayType) Convert() {
at.convertResult[i] = val[i]
}
}
return at.convertResult, nil
}
// ConvertIgnoreError 类型转换并忽略异常
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 18:07 2023/6/26
func (at *ArrayType) ConvertIgnoreError() []interface{} {
res, _ := at.Convert()
return res
}
// Unique 对数据结果进行去重