Skip to content

Commit

Permalink
调整:types.ListAdd的参数为非指针类型
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed Nov 19, 2023
1 parent d0d975a commit 402fddb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion parse/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func Convert[T any](source any, defVal T) T {
lstItemType := types.GetListItemType(defValType)
arr := strings.Split(strSource, ",")
for i := 0; i < len(arr); i++ {
types.ListAdd(&lstReflectValue, ConvertValue(arr[i], lstItemType).Interface())
types.ListAdd(lstReflectValue, ConvertValue(arr[i], lstItemType).Interface())
}
return lstReflectValue.Elem().Interface().(T)
}
Expand Down
2 changes: 1 addition & 1 deletion types/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func ListNew(lstType reflect.Type) reflect.Value {
}

// ListAdd 动态添加元素
func ListAdd(lstValue *reflect.Value, item any) {
func ListAdd(lstValue reflect.Value, item any) {
itemValue := reflect.ValueOf(item)
if itemValue.Kind() == reflect.Ptr {
itemValue = itemValue.Elem()
Expand Down

0 comments on commit 402fddb

Please sign in to comment.