Skip to content

Commit 3770717

Browse files
authored
chore: migrate from interface{} to any (#4817)
1 parent cc11c7d commit 3770717

File tree

211 files changed

+1545
-1540
lines changed

Some content is hidden

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

211 files changed

+1545
-1540
lines changed

.golangci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ formatters:
1111
- gofumpt # Gofumpt checks whether code was gofumpt-ed. [fast: true, auto-fix: true]
1212
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt. [fast: true, auto-fix: true]
1313
- golines
14+
settings:
15+
gofmt:
16+
rewrite-rules:
17+
- pattern: interface{}
18+
replacement: any
1419

1520
linters:
1621
default: none

cmd/scw/web_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func Test_WebValidateTemplatesVariables(t *testing.T) {
5454
if err != nil {
5555
continue
5656
}
57-
var args interface{}
57+
var args any
5858
if cmd.ArgsType != nil {
5959
args = reflect.New(cmd.ArgsType).Interface()
6060
}

core/arg_file_content.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
// loadArgsFileContent will hydrate args with default values.
15-
func loadArgsFileContent(cmd *Command, cmdArgs interface{}) error {
15+
func loadArgsFileContent(cmd *Command, cmdArgs any) error {
1616
for _, argSpec := range cmd.ArgSpecs {
1717
if !argSpec.CanLoadFile {
1818
continue

core/arg_specs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func ZoneArgSpec(zones ...scw.Zone) *ArgSpec {
145145
Name: "zone",
146146
Short: "Zone to target. If none is passed will use default zone from the config",
147147
EnumValues: enumValues,
148-
ValidateFunc: func(_ *ArgSpec, value interface{}) error {
148+
ValidateFunc: func(_ *ArgSpec, value any) error {
149149
for _, zone := range zones {
150150
if value.(scw.Zone) == zone {
151151
return nil
@@ -179,7 +179,7 @@ func RegionArgSpec(regions ...scw.Region) *ArgSpec {
179179
Name: "region",
180180
Short: "Region to target. If none is passed will use default region from the config",
181181
EnumValues: enumValues,
182-
ValidateFunc: func(_ *ArgSpec, value interface{}) error {
182+
ValidateFunc: func(_ *ArgSpec, value any) error {
183183
for _, region := range regions {
184184
if value.(scw.Region) == region {
185185
return nil

core/autocomplete_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func testAutocompleteGetCommands() *core.Commands {
4444
EnumValues: []string{"S", "M", "L", "XL", "XXL"},
4545
},
4646
},
47-
WaitFunc: func(_ context.Context, _, _ interface{}) (interface{}, error) {
47+
WaitFunc: func(_ context.Context, _, _ any) (any, error) {
4848
return nil, nil
4949
},
5050
},
@@ -573,7 +573,7 @@ func TestAutocompleteArgs(t *testing.T) {
573573
Verb: "list",
574574
ArgsType: reflect.TypeOf(struct{}{}),
575575
ArgSpecs: core.ArgSpecs{},
576-
Run: func(_ context.Context, _ interface{}) (interface{}, error) {
576+
Run: func(_ context.Context, _ any) (any, error) {
577577
return []*struct {
578578
Name string
579579
}{
@@ -592,7 +592,7 @@ func TestAutocompleteArgs(t *testing.T) {
592592
Verb: "list",
593593
ArgsType: reflect.TypeOf(struct{}{}),
594594
ArgSpecs: core.ArgSpecs{},
595-
Run: func(_ context.Context, _ interface{}) (interface{}, error) {
595+
Run: func(_ context.Context, _ any) (any, error) {
596596
return []*struct {
597597
Name string
598598
}{

core/autocomplete_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func AutocompleteGetArg(
153153
}
154154

155155
if listCmd.Interceptor == nil {
156-
listCmd.Interceptor = func(ctx context.Context, argsI interface{}, runner CommandRunner) (interface{}, error) {
156+
listCmd.Interceptor = func(ctx context.Context, argsI any, runner CommandRunner) (any, error) {
157157
return runner(ctx, argsI)
158158
}
159159
}

core/bootstrap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ type BootstrapConfig struct {
7777
// Bootstrap is the main entry point. It is directly called from main.
7878
// BootstrapConfig.Args is usually os.Args
7979
// BootstrapConfig.Commands is a list of command available in CLI.
80-
func Bootstrap(config *BootstrapConfig) (exitCode int, result interface{}, err error) {
80+
func Bootstrap(config *BootstrapConfig) (exitCode int, result any, err error) {
8181
// Handles Flags
8282
var debug bool
8383
var profileFlag string

core/bootstrap_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestInterruptError(t *testing.T) {
2121
Resource: "interrupt",
2222
Verb: "error",
2323
ArgsType: reflect.TypeOf(args.RawArgs{}),
24-
Run: func(_ context.Context, _ interface{}) (i interface{}, e error) {
24+
Run: func(_ context.Context, _ any) (i any, e error) {
2525
return nil, &interactive.InterruptError{}
2626
},
2727
},
@@ -38,7 +38,7 @@ func TestInterruptError(t *testing.T) {
3838
Resource: "code",
3939
Verb: "error",
4040
ArgsType: reflect.TypeOf(args.RawArgs{}),
41-
Run: func(_ context.Context, _ interface{}) (i interface{}, e error) {
41+
Run: func(_ context.Context, _ any) (i any, e error) {
4242
return nil, &core.CliError{Code: 99}
4343
},
4444
},
@@ -55,7 +55,7 @@ func TestInterruptError(t *testing.T) {
5555
Resource: "empty",
5656
Verb: "error",
5757
ArgsType: reflect.TypeOf(args.RawArgs{}),
58-
Run: func(_ context.Context, _ interface{}) (i interface{}, e error) {
58+
Run: func(_ context.Context, _ any) (i any, e error) {
5959
return nil, &core.CliError{Code: 99, Empty: true}
6060
},
6161
},
@@ -75,7 +75,7 @@ func TestInterruptError(t *testing.T) {
7575
Resource: "empty",
7676
Verb: "error",
7777
ArgsType: reflect.TypeOf(args.RawArgs{}),
78-
Run: func(_ context.Context, _ interface{}) (i interface{}, e error) {
78+
Run: func(_ context.Context, _ any) (i any, e error) {
7979
return nil, &core.CliError{Code: 99, Empty: true}
8080
},
8181
},
@@ -95,7 +95,7 @@ func TestInterruptError(t *testing.T) {
9595
Resource: "empty",
9696
Verb: "success",
9797
ArgsType: reflect.TypeOf(args.RawArgs{}),
98-
Run: func(_ context.Context, _ interface{}) (i interface{}, e error) {
98+
Run: func(_ context.Context, _ any) (i any, e error) {
9999
return &core.SuccessResult{
100100
Empty: true,
101101
Message: "dummy",
@@ -118,7 +118,7 @@ func TestInterruptError(t *testing.T) {
118118
Resource: "empty",
119119
Verb: "success",
120120
ArgsType: reflect.TypeOf(args.RawArgs{}),
121-
Run: func(_ context.Context, _ interface{}) (i interface{}, e error) {
121+
Run: func(_ context.Context, _ any) (i any, e error) {
122122
return &core.SuccessResult{
123123
Empty: true,
124124
Message: "dummy",
@@ -141,7 +141,7 @@ func TestInterruptError(t *testing.T) {
141141
Resource: "empty",
142142
Verb: "success",
143143
ArgsType: reflect.TypeOf(args.RawArgs{}),
144-
Run: func(_ context.Context, _ interface{}) (i interface{}, e error) {
144+
Run: func(_ context.Context, _ any) (i any, e error) {
145145
return []int(nil), nil
146146
},
147147
AllowAnonymousClient: true,

core/build_info_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var fakeCommand = &core.Command{
1919
Namespace: "plop",
2020
ArgsType: reflect.TypeOf(args.RawArgs{}),
2121
AllowAnonymousClient: true,
22-
Run: func(_ context.Context, _ interface{}) (i interface{}, e error) {
22+
Run: func(_ context.Context, _ any) (i any, e error) {
2323
return &core.SuccessResult{}, nil
2424
},
2525
}

core/checks_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestCheckAPIKey(t *testing.T) {
2121
Namespace: "test",
2222
ArgSpecs: core.ArgSpecs{},
2323
ArgsType: reflect.TypeOf(testType{}),
24-
Run: func(ctx context.Context, _ interface{}) (i interface{}, e error) {
24+
Run: func(ctx context.Context, _ any) (i any, e error) {
2525
// Test command reload the client so the profile used is the edited one
2626
return "", core.ReloadClient(ctx)
2727
},

0 commit comments

Comments
 (0)