Skip to content

Commit 51e1e13

Browse files
authored
*: update interface{} to any (pingcap#50770)
ref pingcap#50765
1 parent 41f56d1 commit 51e1e13

File tree

503 files changed

+4246
-4247
lines changed

Some content is hidden

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

503 files changed

+4246
-4247
lines changed

br/pkg/checkpoint/checkpoint_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestCheckpointMeta(t *testing.T) {
5454
checkpointMetaForRestore := &checkpoint.CheckpointMetadataForRestore{
5555
SchedulersConfig: &pdutil.ClusterConfig{
5656
Schedulers: []string{"1", "2"},
57-
ScheduleCfg: map[string]interface{}{
57+
ScheduleCfg: map[string]any{
5858
"1": "2",
5959
"2": "1",
6060
},
@@ -99,7 +99,7 @@ func TestCheckpointMeta(t *testing.T) {
9999
TableName: model.NewCIStr("3"),
100100
IndexName: "4",
101101
AddSQL: "5",
102-
AddArgs: []interface{}{"6", "7", "8"},
102+
AddArgs: []any{"6", "7", "8"},
103103
},
104104
},
105105
}, "123")
@@ -111,7 +111,7 @@ func TestCheckpointMeta(t *testing.T) {
111111
require.Equal(t, repairSQLs.SQLs[0].TableName, model.NewCIStr("3"))
112112
require.Equal(t, repairSQLs.SQLs[0].IndexName, "4")
113113
require.Equal(t, repairSQLs.SQLs[0].AddSQL, "5")
114-
require.Equal(t, repairSQLs.SQLs[0].AddArgs, []interface{}{"6", "7", "8"})
114+
require.Equal(t, repairSQLs.SQLs[0].AddArgs, []any{"6", "7", "8"})
115115
}
116116

117117
type mockTimer struct {

br/pkg/checkpoint/log_restore.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,12 @@ func removeCheckpointTaskInfoForLogRestore(ctx context.Context, s storage.Extern
247247
}
248248

249249
type CheckpointIngestIndexRepairSQL struct {
250-
IndexID int64 `json:"index-id"`
251-
SchemaName model.CIStr `json:"schema-name"`
252-
TableName model.CIStr `json:"table-name"`
253-
IndexName string `json:"index-name"`
254-
AddSQL string `json:"add-sql"`
255-
AddArgs []interface{} `json:"add-args"`
250+
IndexID int64 `json:"index-id"`
251+
SchemaName model.CIStr `json:"schema-name"`
252+
TableName model.CIStr `json:"table-name"`
253+
IndexName string `json:"index-name"`
254+
AddSQL string `json:"add-sql"`
255+
AddArgs []any `json:"add-args"`
256256
}
257257

258258
type CheckpointIngestIndexRepairSQLs struct {

br/pkg/config/ebs.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ type ClusterInfo struct {
6666
type Kubernetes struct {
6767
PVs []*corev1.PersistentVolume `json:"pvs" toml:"pvs"`
6868
PVCs []*corev1.PersistentVolumeClaim `json:"pvcs" toml:"pvcs"`
69-
CRD interface{} `json:"crd_tidb_cluster" toml:"crd_tidb_cluster"`
70-
Options map[string]interface{} `json:"options" toml:"options"`
69+
CRD any `json:"crd_tidb_cluster" toml:"crd_tidb_cluster"`
70+
Options map[string]any `json:"options" toml:"options"`
7171
}
7272

7373
type TiKVComponent struct {
@@ -84,13 +84,13 @@ type TiDBComponent struct {
8484
}
8585

8686
type EBSBasedBRMeta struct {
87-
ClusterInfo *ClusterInfo `json:"cluster_info" toml:"cluster_info"`
88-
TiKVComponent *TiKVComponent `json:"tikv" toml:"tikv"`
89-
TiDBComponent *TiDBComponent `json:"tidb" toml:"tidb"`
90-
PDComponent *PDComponent `json:"pd" toml:"pd"`
91-
KubernetesMeta *Kubernetes `json:"kubernetes" toml:"kubernetes"`
92-
Options map[string]interface{} `json:"options" toml:"options"`
93-
Region string `json:"region" toml:"region"`
87+
ClusterInfo *ClusterInfo `json:"cluster_info" toml:"cluster_info"`
88+
TiKVComponent *TiKVComponent `json:"tikv" toml:"tikv"`
89+
TiDBComponent *TiDBComponent `json:"tidb" toml:"tidb"`
90+
PDComponent *PDComponent `json:"pd" toml:"pd"`
91+
KubernetesMeta *Kubernetes `json:"kubernetes" toml:"kubernetes"`
92+
Options map[string]any `json:"options" toml:"options"`
93+
Region string `json:"region" toml:"region"`
9494
}
9595

9696
func (c *EBSBasedBRMeta) GetStoreCount() uint64 {

br/pkg/glue/console_glue.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func WithTimeCost() ExtraField {
3838
}
3939

4040
// WithConstExtraField adds an extra field with constant values.
41-
func WithConstExtraField(key string, value interface{}) ExtraField {
41+
func WithConstExtraField(key string, value any) ExtraField {
4242
return func() [2]string {
4343
return [2]string{key, fmt.Sprint(value)}
4444
}
@@ -114,7 +114,7 @@ func (ops ConsoleOperations) IsInteractive() bool {
114114
return term.IsTerminal(int(f.Fd()))
115115
}
116116

117-
func (ops ConsoleOperations) Scanln(args ...interface{}) (int, error) {
117+
func (ops ConsoleOperations) Scanln(args ...any) (int, error) {
118118
return fmt.Fscanln(ops.In(), args...)
119119
}
120120

@@ -136,15 +136,15 @@ func (ops ConsoleOperations) CreateTable() *Table {
136136
}
137137
}
138138

139-
func (ops ConsoleOperations) Print(args ...interface{}) {
139+
func (ops ConsoleOperations) Print(args ...any) {
140140
_, _ = fmt.Fprint(ops.Out(), args...)
141141
}
142142

143-
func (ops ConsoleOperations) Println(args ...interface{}) {
143+
func (ops ConsoleOperations) Println(args ...any) {
144144
_, _ = fmt.Fprintln(ops.Out(), args...)
145145
}
146146

147-
func (ops ConsoleOperations) Printf(format string, args ...interface{}) {
147+
func (ops ConsoleOperations) Printf(format string, args ...any) {
148148
_, _ = fmt.Fprintf(ops.Out(), format, args...)
149149
}
150150

br/pkg/glue/glue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type Glue interface {
4141
// Session is an abstraction of the session.Session interface.
4242
type Session interface {
4343
Execute(ctx context.Context, sql string) error
44-
ExecuteInternal(ctx context.Context, sql string, args ...interface{}) error
44+
ExecuteInternal(ctx context.Context, sql string, args ...any) error
4545
CreateDatabase(ctx context.Context, schema *model.DBInfo) error
4646
CreateTable(ctx context.Context, dbName model.CIStr, table *model.TableInfo,
4747
cs ...ddl.CreateTableWithInfoConfigurier) error

br/pkg/gluetidb/glue.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func (gs *tidbSession) Execute(ctx context.Context, sql string) error {
168168
return gs.ExecuteInternal(ctx, sql)
169169
}
170170

171-
func (gs *tidbSession) ExecuteInternal(ctx context.Context, sql string, args ...interface{}) error {
171+
func (gs *tidbSession) ExecuteInternal(ctx context.Context, sql string, args ...any) error {
172172
ctx = kv.WithInternalSourceType(ctx, kv.InternalTxnBR)
173173
rs, err := gs.se.ExecuteInternal(ctx, sql, args...)
174174
if err != nil {
@@ -252,7 +252,7 @@ func (s *mockSession) Execute(ctx context.Context, sql string) error {
252252
return s.ExecuteInternal(ctx, sql)
253253
}
254254

255-
func (s *mockSession) ExecuteInternal(ctx context.Context, sql string, args ...interface{}) error {
255+
func (s *mockSession) ExecuteInternal(ctx context.Context, sql string, args ...any) error {
256256
ctx = kv.WithInternalSourceType(ctx, kv.InternalTxnBR)
257257
rs, err := s.se.ExecuteInternal(ctx, sql, args...)
258258
if err != nil {

br/pkg/lightning/backend/external/iter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ func (h mergeHeap[T]) Swap(i, j int) {
7474
h[i], h[j] = h[j], h[i]
7575
}
7676

77-
func (h *mergeHeap[T]) Push(x interface{}) {
77+
func (h *mergeHeap[T]) Push(x any) {
7878
*h = append(*h, x.(mergeHeapElem[T]))
7979
}
8080

81-
func (h *mergeHeap[T]) Pop() interface{} {
81+
func (h *mergeHeap[T]) Pop() any {
8282
old := *h
8383
n := len(old)
8484
x := old[n-1]

br/pkg/lightning/backend/external/split.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ func (h exhaustedHeap) Swap(i, j int) {
4545
h[i], h[j] = h[j], h[i]
4646
}
4747

48-
func (h *exhaustedHeap) Push(x interface{}) {
48+
func (h *exhaustedHeap) Push(x any) {
4949
*h = append(*h, x.(exhaustedHeapElem))
5050
}
5151

52-
func (h *exhaustedHeap) Pop() interface{} {
52+
func (h *exhaustedHeap) Pop() any {
5353
old := *h
5454
n := len(old)
5555
x := old[n-1]

br/pkg/lightning/backend/kv/session.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ type Session struct {
268268
txn transaction
269269
Vars *variable.SessionVars
270270
// currently, we only set `CommonAddRecordCtx`
271-
values map[fmt.Stringer]interface{}
271+
values map[fmt.Stringer]any
272272
}
273273

274274
// NewSessionCtx creates a new trimmed down Session matching the options.
@@ -279,7 +279,7 @@ func NewSessionCtx(options *encode.SessionOptions, logger log.Logger) sessionctx
279279
// NewSession creates a new trimmed down Session matching the options.
280280
func NewSession(options *encode.SessionOptions, logger log.Logger) *Session {
281281
s := &Session{
282-
values: make(map[fmt.Stringer]interface{}, 1),
282+
values: make(map[fmt.Stringer]any, 1),
283283
}
284284
sqlMode := options.SQLMode
285285
vars := variable.NewSessionVars(s)
@@ -354,12 +354,12 @@ func (se *Session) GetSessionVars() *variable.SessionVars {
354354
}
355355

356356
// SetValue saves a value associated with this context for key.
357-
func (se *Session) SetValue(key fmt.Stringer, value interface{}) {
357+
func (se *Session) SetValue(key fmt.Stringer, value any) {
358358
se.values[key] = value
359359
}
360360

361361
// Value returns the value associated with this context for key.
362-
func (se *Session) Value(key fmt.Stringer) interface{} {
362+
func (se *Session) Value(key fmt.Stringer) any {
363363
return se.values[key]
364364
}
365365

br/pkg/lightning/backend/kv/sql2kv_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ func TestMarshal(t *testing.T) {
5252
encoder := zapcore.NewMapObjectEncoder()
5353
err := encoder.AddArray("test", lkv.RowArrayMarshaller{types.NewStringDatum("1"), nullDatum, minNotNull, types.MaxValueDatum()})
5454
require.NoError(t, err)
55-
require.Equal(t, encoder.Fields["test"], []interface{}{
56-
map[string]interface{}{"kind": "string", "val": "1"},
57-
map[string]interface{}{"kind": "null", "val": "NULL"},
58-
map[string]interface{}{"kind": "min", "val": "-inf"},
59-
map[string]interface{}{"kind": "max", "val": "+inf"},
55+
require.Equal(t, encoder.Fields["test"], []any{
56+
map[string]any{"kind": "string", "val": "1"},
57+
map[string]any{"kind": "null", "val": "NULL"},
58+
map[string]any{"kind": "min", "val": "-inf"},
59+
map[string]any{"kind": "max", "val": "+inf"},
6060
})
6161

6262
invalid := types.Datum{}
6363
invalid.SetInterface(1)
6464
err = encoder.AddArray("bad-test", lkv.RowArrayMarshaller{minNotNull, invalid})
6565
require.Regexp(t, "cannot convert.*", err)
66-
require.Equal(t, encoder.Fields["bad-test"], []interface{}{
67-
map[string]interface{}{"kind": "min", "val": "-inf"},
66+
require.Equal(t, encoder.Fields["bad-test"], []any{
67+
map[string]any{"kind": "min", "val": "-inf"},
6868
})
6969
}
7070

0 commit comments

Comments
 (0)