Skip to content

Commit 2c63d1d

Browse files
authored
all: gofmt -w -r 'interface{} -> any' (ent#2874)
1 parent b6c185a commit 2c63d1d

File tree

619 files changed

+3449
-3449
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

619 files changed

+3449
-3449
lines changed

cmd/internal/base/packages_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func testPkgPath(t *testing.T, x packagestest.Exporter) {
1717
e := packagestest.Export(t, x, []packagestest.Module{
1818
{
1919
Name: "golang.org/x",
20-
Files: map[string]interface{}{
20+
Files: map[string]any{
2121
"x.go": "package x",
2222
"y/y.go": "package y",
2323
},

dialect/dialect.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ const (
2626
type ExecQuerier interface {
2727
// Exec executes a query that does not return records. For example, in SQL, INSERT or UPDATE.
2828
// It scans the result into the pointer v. For SQL drivers, it is dialect/sql.Result.
29-
Exec(ctx context.Context, query string, args, v interface{}) error
29+
Exec(ctx context.Context, query string, args, v any) error
3030
// Query executes a query that returns rows, typically a SELECT in SQL.
3131
// It scans the result into the pointer v. For SQL drivers, it is *dialect/sql.Rows.
32-
Query(ctx context.Context, query string, args, v interface{}) error
32+
Query(ctx context.Context, query string, args, v any) error
3333
}
3434

3535
// Driver is the interface that wraps all necessary operations for ent clients.
@@ -65,38 +65,38 @@ func NopTx(d Driver) Tx {
6565

6666
// DebugDriver is a driver that logs all driver operations.
6767
type DebugDriver struct {
68-
Driver // underlying driver.
69-
log func(context.Context, ...interface{}) // log function. defaults to log.Println.
68+
Driver // underlying driver.
69+
log func(context.Context, ...any) // log function. defaults to log.Println.
7070
}
7171

7272
// Debug gets a driver and an optional logging function, and returns
7373
// a new debugged-driver that prints all outgoing operations.
74-
func Debug(d Driver, logger ...func(...interface{})) Driver {
74+
func Debug(d Driver, logger ...func(...any)) Driver {
7575
logf := log.Println
7676
if len(logger) == 1 {
7777
logf = logger[0]
7878
}
79-
drv := &DebugDriver{d, func(_ context.Context, v ...interface{}) { logf(v...) }}
79+
drv := &DebugDriver{d, func(_ context.Context, v ...any) { logf(v...) }}
8080
return drv
8181
}
8282

8383
// DebugWithContext gets a driver and a logging function, and returns
8484
// a new debugged-driver that prints all outgoing operations with context.
85-
func DebugWithContext(d Driver, logger func(context.Context, ...interface{})) Driver {
85+
func DebugWithContext(d Driver, logger func(context.Context, ...any)) Driver {
8686
drv := &DebugDriver{d, logger}
8787
return drv
8888
}
8989

9090
// Exec logs its params and calls the underlying driver Exec method.
91-
func (d *DebugDriver) Exec(ctx context.Context, query string, args, v interface{}) error {
91+
func (d *DebugDriver) Exec(ctx context.Context, query string, args, v any) error {
9292
d.log(ctx, fmt.Sprintf("driver.Exec: query=%v args=%v", query, args))
9393
return d.Driver.Exec(ctx, query, args, v)
9494
}
9595

9696
// ExecContext logs its params and calls the underlying driver ExecContext method if it is supported.
97-
func (d *DebugDriver) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) {
97+
func (d *DebugDriver) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) {
9898
drv, ok := d.Driver.(interface {
99-
ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
99+
ExecContext(context.Context, string, ...any) (sql.Result, error)
100100
})
101101
if !ok {
102102
return nil, fmt.Errorf("Driver.ExecContext is not supported")
@@ -106,15 +106,15 @@ func (d *DebugDriver) ExecContext(ctx context.Context, query string, args ...int
106106
}
107107

108108
// Query logs its params and calls the underlying driver Query method.
109-
func (d *DebugDriver) Query(ctx context.Context, query string, args, v interface{}) error {
109+
func (d *DebugDriver) Query(ctx context.Context, query string, args, v any) error {
110110
d.log(ctx, fmt.Sprintf("driver.Query: query=%v args=%v", query, args))
111111
return d.Driver.Query(ctx, query, args, v)
112112
}
113113

114114
// QueryContext logs its params and calls the underlying driver QueryContext method if it is supported.
115-
func (d *DebugDriver) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) {
115+
func (d *DebugDriver) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) {
116116
drv, ok := d.Driver.(interface {
117-
QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
117+
QueryContext(context.Context, string, ...any) (*sql.Rows, error)
118118
})
119119
if !ok {
120120
return nil, fmt.Errorf("Driver.QueryContext is not supported")
@@ -153,22 +153,22 @@ func (d *DebugDriver) BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, err
153153

154154
// DebugTx is a transaction implementation that logs all transaction operations.
155155
type DebugTx struct {
156-
Tx // underlying transaction.
157-
id string // transaction logging id.
158-
log func(context.Context, ...interface{}) // log function. defaults to fmt.Println.
159-
ctx context.Context // underlying transaction context.
156+
Tx // underlying transaction.
157+
id string // transaction logging id.
158+
log func(context.Context, ...any) // log function. defaults to fmt.Println.
159+
ctx context.Context // underlying transaction context.
160160
}
161161

162162
// Exec logs its params and calls the underlying transaction Exec method.
163-
func (d *DebugTx) Exec(ctx context.Context, query string, args, v interface{}) error {
163+
func (d *DebugTx) Exec(ctx context.Context, query string, args, v any) error {
164164
d.log(ctx, fmt.Sprintf("Tx(%s).Exec: query=%v args=%v", d.id, query, args))
165165
return d.Tx.Exec(ctx, query, args, v)
166166
}
167167

168168
// ExecContext logs its params and calls the underlying transaction ExecContext method if it is supported.
169-
func (d *DebugTx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) {
169+
func (d *DebugTx) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) {
170170
drv, ok := d.Tx.(interface {
171-
ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
171+
ExecContext(context.Context, string, ...any) (sql.Result, error)
172172
})
173173
if !ok {
174174
return nil, fmt.Errorf("Tx.ExecContext is not supported")
@@ -178,15 +178,15 @@ func (d *DebugTx) ExecContext(ctx context.Context, query string, args ...interfa
178178
}
179179

180180
// Query logs its params and calls the underlying transaction Query method.
181-
func (d *DebugTx) Query(ctx context.Context, query string, args, v interface{}) error {
181+
func (d *DebugTx) Query(ctx context.Context, query string, args, v any) error {
182182
d.log(ctx, fmt.Sprintf("Tx(%s).Query: query=%v args=%v", d.id, query, args))
183183
return d.Tx.Query(ctx, query, args, v)
184184
}
185185

186186
// QueryContext logs its params and calls the underlying transaction QueryContext method if it is supported.
187-
func (d *DebugTx) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) {
187+
func (d *DebugTx) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) {
188188
drv, ok := d.Tx.(interface {
189-
QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
189+
QueryContext(context.Context, string, ...any) (*sql.Rows, error)
190190
})
191191
if !ok {
192192
return nil, fmt.Errorf("Tx.QueryContext is not supported")

dialect/gremlin/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ func (c Client) Query(ctx context.Context, query string) (*Response, error) {
7272
}
7373

7474
// Queryf formats a query string and invokes Query.
75-
func (c Client) Queryf(ctx context.Context, format string, args ...interface{}) (*Response, error) {
75+
func (c Client) Queryf(ctx context.Context, format string, args ...any) (*Response, error) {
7676
return c.Query(ctx, fmt.Sprintf(format, args...))
7777
}

dialect/gremlin/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,6 @@ func TestExpandOrdering(t *testing.T) {
149149
}
150150
c, err := cfg.Build(WithInterceptor(interceptor))
151151
require.NoError(t, err)
152-
req := NewEvalRequest("g.V().hasLabel($1)", WithBindings(map[string]interface{}{"$1": "user"}))
152+
req := NewEvalRequest("g.V().hasLabel($1)", WithBindings(map[string]any{"$1": "user"}))
153153
_, _ = c.Do(context.Background(), req)
154154
}

dialect/gremlin/driver.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ func NewDriver(c *Client) *Driver {
2727
func (Driver) Dialect() string { return dialect.Gremlin }
2828

2929
// Exec implements the dialect.Exec method.
30-
func (c *Driver) Exec(ctx context.Context, query string, args, v interface{}) error {
30+
func (c *Driver) Exec(ctx context.Context, query string, args, v any) error {
3131
vr, ok := v.(*Response)
3232
if !ok {
3333
return fmt.Errorf("dialect/gremlin: invalid type %T. expect *gremlin.Response", v)
3434
}
3535
bindings, ok := args.(dsl.Bindings)
3636
if !ok {
37-
return fmt.Errorf("dialect/gremlin: invalid type %T. expect map[string]interface{} for bindings", args)
37+
return fmt.Errorf("dialect/gremlin: invalid type %T. expect map[string]any for bindings", args)
3838
}
3939
res, err := c.Do(ctx, NewEvalRequest(query, WithBindings(bindings)))
4040
if err != nil {
@@ -45,7 +45,7 @@ func (c *Driver) Exec(ctx context.Context, query string, args, v interface{}) er
4545
}
4646

4747
// Query implements the dialect.Query method.
48-
func (c *Driver) Query(ctx context.Context, query string, args, v interface{}) error {
48+
func (c *Driver) Query(ctx context.Context, query string, args, v any) error {
4949
return c.Exec(ctx, query, args, v)
5050
}
5151

dialect/gremlin/encoding/graphson/bench_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func BenchmarkMarshalInterface(b *testing.B) {
6666
b.Fatal(err)
6767
}
6868

69-
var obj interface{}
69+
var obj any
7070
if err = jsoniter.Unmarshal(data, &obj); err != nil {
7171
b.Fatal(err)
7272
}
@@ -87,7 +87,7 @@ func BenchmarkUnmarshalInterface(b *testing.B) {
8787
b.Fatal(err)
8888
}
8989

90-
var obj interface{}
90+
var obj any
9191

9292
b.ResetTimer()
9393
for n := 0; n < b.N; n++ {

dialect/gremlin/encoding/graphson/decode.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ type decodeExtension struct {
1818

1919
// Unmarshal parses the graphson encoded data and stores the result
2020
// in the value pointed to by v.
21-
func Unmarshal(data []byte, v interface{}) error {
21+
func Unmarshal(data []byte, v any) error {
2222
return config.Unmarshal(data, v)
2323
}
2424

2525
// UnmarshalFromString parses the graphson encoded str and stores the result
2626
// in the value pointed to by v.
27-
func UnmarshalFromString(str string, v interface{}) error {
27+
func UnmarshalFromString(str string, v any) error {
2828
return config.UnmarshalFromString(str, v)
2929
}
3030

3131
// Decoder defines a graphson decoder.
3232
type Decoder interface {
33-
Decode(interface{}) error
33+
Decode(any) error
3434
}
3535

3636
// NewDecoder create a graphson decoder.

dialect/gremlin/encoding/graphson/encode.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ type encodeExtension struct {
1717
}
1818

1919
// Marshal returns the graphson encoding of v.
20-
func Marshal(v interface{}) ([]byte, error) {
20+
func Marshal(v any) ([]byte, error) {
2121
return config.Marshal(v)
2222
}
2323

2424
// MarshalToString returns the graphson encoding of v as string.
25-
func MarshalToString(v interface{}) (string, error) {
25+
func MarshalToString(v any) (string, error) {
2626
return config.MarshalToString(v)
2727
}
2828

2929
// Encoder defines a graphson encoder.
3030
type Encoder interface {
31-
Encode(interface{}) error
31+
Encode(any) error
3232
}
3333

3434
// NewEncoder create a graphson encoder.

dialect/gremlin/encoding/graphson/error.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ import (
1212
)
1313

1414
// EncoderOfError returns a value encoder which always fails to encode.
15-
func (encodeExtension) EncoderOfError(format string, args ...interface{}) jsoniter.ValEncoder {
15+
func (encodeExtension) EncoderOfError(format string, args ...any) jsoniter.ValEncoder {
1616
return decoratorOfError(format, args...)
1717
}
1818

1919
// DecoderOfError returns a value decoder which always fails to decode.
20-
func (decodeExtension) DecoderOfError(format string, args ...interface{}) jsoniter.ValDecoder {
20+
func (decodeExtension) DecoderOfError(format string, args ...any) jsoniter.ValDecoder {
2121
return decoratorOfError(format, args...)
2222
}
2323

24-
func decoratorOfError(format string, args ...interface{}) errorCodec {
24+
func decoratorOfError(format string, args ...any) errorCodec {
2525
err := fmt.Errorf(format, args...)
2626
return errorCodec{err}
2727
}

dialect/gremlin/encoding/graphson/interface.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (dec efaceDecoder) decode(ptr unsafe.Pointer, iter *jsoniter.Iterator) {
5555
it := config.BorrowIterator(data)
5656
defer config.ReturnIterator(it)
5757

58-
var val interface{}
58+
var val any
5959
if rtype != nil {
6060
val = rtype.New()
6161
it.ReadVal(val)
@@ -120,30 +120,30 @@ func (efaceDecoder) reflectType(typ Type) reflect2.Type {
120120
}
121121

122122
func (efaceDecoder) reflectSlice(data []byte) (reflect2.Type, error) {
123-
var elem interface{}
124-
if err := Unmarshal(data, &[...]*interface{}{&elem}); err != nil {
123+
var elem any
124+
if err := Unmarshal(data, &[...]*any{&elem}); err != nil {
125125
return nil, fmt.Errorf("cannot read first list element: %w", err)
126126
}
127127

128128
if elem == nil {
129-
return reflect2.TypeOf([]interface{}{}), nil
129+
return reflect2.TypeOf([]any{}), nil
130130
}
131131

132132
sliceType := reflect.SliceOf(reflect.TypeOf(elem))
133133
return reflect2.Type2(sliceType), nil
134134
}
135135

136136
func (efaceDecoder) reflectMap(data []byte) (reflect2.Type, error) {
137-
var key, elem interface{}
137+
var key, elem any
138138
if err := Unmarshal(
139139
bytes.Replace(data, []byte(mapType), []byte(listType), 1),
140-
&[...]*interface{}{&key, &elem},
140+
&[...]*any{&key, &elem},
141141
); err != nil {
142142
return nil, fmt.Errorf("cannot unmarshal first map item: %w", err)
143143
}
144144

145145
if key == nil {
146-
return reflect2.TypeOf(map[interface{}]interface{}{}), nil
146+
return reflect2.TypeOf(map[any]any{}), nil
147147
} else if elem == nil {
148148
return nil, errors.New("expect map element, but found only key")
149149
}

0 commit comments

Comments
 (0)