chore: update goctl interface{} to any (#2819)

* chore: update goctl interface{} to any

* chore: update goctl interface{} to any
This commit is contained in:
Kevin Wan
2023-01-24 17:51:03 +08:00
committed by GitHub
parent ae87114282
commit eab904af64
32 changed files with 112 additions and 112 deletions

View File

@@ -27,13 +27,13 @@ type rowsScanner interface {
Columns() ([]string, error)
Err() error
Next() bool
Scan(v ...interface{}) error
Scan(v ...any) error
}
func getTaggedFieldValueMap(v reflect.Value) (map[string]interface{}, error) {
func getTaggedFieldValueMap(v reflect.Value) (map[string]any, error) {
rt := mapping.Deref(v.Type())
size := rt.NumField()
result := make(map[string]interface{}, size)
result := make(map[string]any, size)
for i := 0; i < size; i++ {
key := parseTagName(rt.Field(i))
@@ -63,7 +63,7 @@ func getTaggedFieldValueMap(v reflect.Value) (map[string]interface{}, error) {
return result, nil
}
func mapStructFieldsIntoSlice(v reflect.Value, columns []string, strict bool) ([]interface{}, error) {
func mapStructFieldsIntoSlice(v reflect.Value, columns []string, strict bool) ([]any, error) {
fields := unwrapFields(v)
if strict && len(columns) < len(fields) {
return nil, ErrNotMatchDestination
@@ -74,7 +74,7 @@ func mapStructFieldsIntoSlice(v reflect.Value, columns []string, strict bool) ([
return nil, err
}
values := make([]interface{}, len(columns))
values := make([]any, len(columns))
if len(taggedMap) == 0 {
for i := 0; i < len(values); i++ {
valueField := fields[i]
@@ -100,7 +100,7 @@ func mapStructFieldsIntoSlice(v reflect.Value, columns []string, strict bool) ([
if tagged, ok := taggedMap[column]; ok {
values[i] = tagged
} else {
var anonymous interface{}
var anonymous any
values[i] = &anonymous
}
}
@@ -119,7 +119,7 @@ func parseTagName(field reflect.StructField) string {
return options[0]
}
func unmarshalRow(v interface{}, scanner rowsScanner, strict bool) error {
func unmarshalRow(v any, scanner rowsScanner, strict bool) error {
if !scanner.Next() {
if err := scanner.Err(); err != nil {
return err
@@ -161,7 +161,7 @@ func unmarshalRow(v interface{}, scanner rowsScanner, strict bool) error {
}
}
func unmarshalRows(v interface{}, scanner rowsScanner, strict bool) error {
func unmarshalRows(v any, scanner rowsScanner, strict bool) error {
rv := reflect.ValueOf(v)
if err := mapping.ValidatePtr(&rv); err != nil {
return err
@@ -181,7 +181,7 @@ func unmarshalRows(v interface{}, scanner rowsScanner, strict bool) error {
rve.Set(reflect.Append(rve, reflect.Indirect(item)))
}
}
fillFn := func(value interface{}) error {
fillFn := func(value any) error {
if rve.CanSet() {
if err := scanner.Scan(value); err != nil {
return err