mirror of
https://github.com/minio/minio.git
synced 2025-11-09 21:49:46 -05:00
Run modernize (#21546)
`go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./...` executed. `go generate ./...` ran afterwards to keep generated.
This commit is contained in:
@@ -413,7 +413,7 @@ func (e *JSONPath) evalNode(r Record, tableAlias string) (*Value, error) {
|
||||
}
|
||||
|
||||
// jsonToValue will convert the json value to an internal value.
|
||||
func jsonToValue(result interface{}) (*Value, error) {
|
||||
func jsonToValue(result any) (*Value, error) {
|
||||
switch rval := result.(type) {
|
||||
case string:
|
||||
return FromString(rval), nil
|
||||
@@ -434,7 +434,7 @@ func jsonToValue(result interface{}) (*Value, error) {
|
||||
return nil, err
|
||||
}
|
||||
return FromBytes(bs), nil
|
||||
case []interface{}:
|
||||
case []any:
|
||||
dst := make([]Value, len(rval))
|
||||
for i := range rval {
|
||||
v, err := jsonToValue(rval[i])
|
||||
|
||||
@@ -34,7 +34,7 @@ var (
|
||||
|
||||
// jsonpathEval evaluates a JSON path and returns the value at the path.
|
||||
// If the value should be considered flat (from wildcards) any array returned should be considered individual values.
|
||||
func jsonpathEval(p []*JSONPathElement, v interface{}) (r interface{}, flat bool, err error) {
|
||||
func jsonpathEval(p []*JSONPathElement, v any) (r any, flat bool, err error) {
|
||||
// fmt.Printf("JPATHexpr: %v jsonobj: %v\n\n", p, v)
|
||||
if len(p) == 0 || v == nil {
|
||||
return v, false, nil
|
||||
@@ -71,7 +71,7 @@ func jsonpathEval(p []*JSONPathElement, v interface{}) (r interface{}, flat bool
|
||||
case p[0].Index != nil:
|
||||
idx := *p[0].Index
|
||||
|
||||
arr, ok := v.([]interface{})
|
||||
arr, ok := v.([]any)
|
||||
if !ok {
|
||||
return nil, false, errIndexLookup
|
||||
}
|
||||
@@ -100,14 +100,14 @@ func jsonpathEval(p []*JSONPathElement, v interface{}) (r interface{}, flat bool
|
||||
}
|
||||
|
||||
case p[0].ArrayWildcard:
|
||||
arr, ok := v.([]interface{})
|
||||
arr, ok := v.([]any)
|
||||
if !ok {
|
||||
return nil, false, errWildcardArrayLookup
|
||||
}
|
||||
|
||||
// Lookup remainder of path in each array element and
|
||||
// make result array.
|
||||
var result []interface{}
|
||||
var result []any
|
||||
for _, a := range arr {
|
||||
rval, flatten, err := jsonpathEval(p[1:], a)
|
||||
if err != nil {
|
||||
@@ -116,7 +116,7 @@ func jsonpathEval(p []*JSONPathElement, v interface{}) (r interface{}, flat bool
|
||||
|
||||
if flatten {
|
||||
// Flatten if array.
|
||||
if arr, ok := rval.([]interface{}); ok {
|
||||
if arr, ok := rval.([]any); ok {
|
||||
result = append(result, arr...)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@ import (
|
||||
"github.com/minio/minio/internal/s3select/jstream"
|
||||
)
|
||||
|
||||
func getJSONStructs(b []byte) ([]interface{}, error) {
|
||||
func getJSONStructs(b []byte) ([]any, error) {
|
||||
dec := jstream.NewDecoder(bytes.NewBuffer(b), 0).ObjectAsKVS().MaxDepth(100)
|
||||
var result []interface{}
|
||||
var result []any
|
||||
for parsedVal := range dec.Stream() {
|
||||
result = append(result, parsedVal.Value)
|
||||
}
|
||||
@@ -60,13 +60,13 @@ func TestJsonpathEval(t *testing.T) {
|
||||
)
|
||||
cases := []struct {
|
||||
str string
|
||||
res []interface{}
|
||||
res []any
|
||||
}{
|
||||
{"s.title", []interface{}{"Murder on the Orient Express", "The Robots of Dawn", "Pigs Have Wings"}},
|
||||
{"s.authorInfo.yearRange", []interface{}{[]interface{}{1890.0, 1976.0}, []interface{}{1920.0, 1992.0}, []interface{}{1881.0, 1975.0}}},
|
||||
{"s.authorInfo.name", []interface{}{"Agatha Christie", "Isaac Asimov", "P. G. Wodehouse"}},
|
||||
{"s.authorInfo.yearRange[0]", []interface{}{1890.0, 1920.0, 1881.0}},
|
||||
{"s.publicationHistory[0].pages", []interface{}{256.0, 336.0, Missing{}}},
|
||||
{"s.title", []any{"Murder on the Orient Express", "The Robots of Dawn", "Pigs Have Wings"}},
|
||||
{"s.authorInfo.yearRange", []any{[]any{1890.0, 1976.0}, []any{1920.0, 1992.0}, []any{1881.0, 1975.0}}},
|
||||
{"s.authorInfo.name", []any{"Agatha Christie", "Isaac Asimov", "P. G. Wodehouse"}},
|
||||
{"s.authorInfo.yearRange[0]", []any{1890.0, 1920.0, 1881.0}},
|
||||
{"s.publicationHistory[0].pages", []any{256.0, 336.0, Missing{}}},
|
||||
}
|
||||
for i, tc := range cases {
|
||||
t.Run(tc.str, func(t *testing.T) {
|
||||
|
||||
@@ -63,16 +63,16 @@ type Record interface {
|
||||
Reset()
|
||||
|
||||
// Returns underlying representation
|
||||
Raw() (SelectObjectFormat, interface{})
|
||||
Raw() (SelectObjectFormat, any)
|
||||
|
||||
// Replaces the underlying data
|
||||
Replace(k interface{}) error
|
||||
Replace(k any) error
|
||||
}
|
||||
|
||||
// IterToValue converts a simdjson Iter to its underlying value.
|
||||
// Objects are returned as simdjson.Object
|
||||
// Arrays are returned as []interface{} with parsed values.
|
||||
func IterToValue(iter simdjson.Iter) (interface{}, error) {
|
||||
func IterToValue(iter simdjson.Iter) (any, error) {
|
||||
switch iter.Type() {
|
||||
case simdjson.TypeString:
|
||||
v, err := iter.String()
|
||||
@@ -118,7 +118,7 @@ func IterToValue(iter simdjson.Iter) (interface{}, error) {
|
||||
return nil, err
|
||||
}
|
||||
iter := arr.Iter()
|
||||
var dst []interface{}
|
||||
var dst []any
|
||||
var next simdjson.Iter
|
||||
for {
|
||||
typ, err := iter.AdvanceIter(&next)
|
||||
|
||||
@@ -174,7 +174,7 @@ func (e *SelectStatement) EvalFrom(format string, input Record) ([]*Record, erro
|
||||
case jstream.KVS:
|
||||
kvs = v
|
||||
|
||||
case []interface{}:
|
||||
case []any:
|
||||
recs := make([]*Record, len(v))
|
||||
for i, val := range v {
|
||||
tmpRec := input.Clone(nil)
|
||||
@@ -207,7 +207,7 @@ func (e *SelectStatement) EvalFrom(format string, input Record) ([]*Record, erro
|
||||
return nil, err
|
||||
}
|
||||
|
||||
case []interface{}:
|
||||
case []any:
|
||||
recs := make([]*Record, len(v))
|
||||
for i, val := range v {
|
||||
tmpRec := input.Clone(nil)
|
||||
|
||||
@@ -46,7 +46,7 @@ var (
|
||||
// the type may not be determined yet. In these cases, a byte-slice is
|
||||
// used.
|
||||
type Value struct {
|
||||
value interface{}
|
||||
value any
|
||||
}
|
||||
|
||||
// Missing is used to indicate a non-existing value.
|
||||
|
||||
@@ -217,7 +217,7 @@ func TestValue_CSVString(t *testing.T) {
|
||||
|
||||
func TestValue_bytesToInt(t *testing.T) {
|
||||
type fields struct {
|
||||
value interface{}
|
||||
value any
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -367,7 +367,7 @@ func TestValue_bytesToInt(t *testing.T) {
|
||||
|
||||
func TestValue_bytesToFloat(t *testing.T) {
|
||||
type fields struct {
|
||||
value interface{}
|
||||
value any
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -569,7 +569,7 @@ func TestValue_bytesToFloat(t *testing.T) {
|
||||
|
||||
func TestValue_bytesToBool(t *testing.T) {
|
||||
type fields struct {
|
||||
value interface{}
|
||||
value any
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user