diff --git a/array.go b/array.go index 1e2c966..99b0bf5 100644 --- a/array.go +++ b/array.go @@ -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 对数据结果进行去重