Skip to content

Commit f4c4485

Browse files
lucasoskorepAlex Boten
andauthored
[all][chore] Moved from interface{} to any for all go code (open-telemetry#29072)
Additionally added a golangci-lint.yaml update to automatically apply this change to new code going forward Fixes open-telemetry#23811 --------- Co-authored-by: Alex Boten <aboten@lightstep.com>
1 parent 330ff0a commit f4c4485

File tree

581 files changed

+4888
-4886
lines changed

Some content is hidden

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

581 files changed

+4888
-4886
lines changed

.golangci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ linters-settings:
8787
gofmt:
8888
# simplify code: gofmt with `-s` option, true by default
8989
simplify: true
90+
rewrite-rules:
91+
- pattern: interface{}
92+
replacement: any
9093

9194
goimports:
9295
# put imports beginning with prefix after 3rd-party packages;

cmd/configschema/configs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type CfgInfo struct {
2626
// the component type, e.g. "otlpreceiver.Config"
2727
Type component.Type
2828
// an instance of the component's configuration struct
29-
CfgInstance interface{}
29+
CfgInstance any
3030
}
3131

3232
// GetAllCfgInfos accepts a Factories struct, then creates and returns a CfgInfo

cmd/configschema/fields.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import (
1414

1515
// Field holds attributes and subfields of a config struct.
1616
type Field struct {
17-
Name string `yaml:",omitempty"`
18-
Type string `yaml:",omitempty"`
19-
Kind string `yaml:",omitempty"`
20-
Default interface{} `yaml:",omitempty"`
21-
Doc string `yaml:",omitempty"`
22-
Fields []*Field `yaml:",omitempty"`
17+
Name string `yaml:",omitempty"`
18+
Type string `yaml:",omitempty"`
19+
Kind string `yaml:",omitempty"`
20+
Default any `yaml:",omitempty"`
21+
Doc string `yaml:",omitempty"`
22+
Fields []*Field `yaml:",omitempty"`
2323
}
2424

2525
// ReadFields accepts both a config struct's Value, as well as a DirResolver,

cmd/configschema/fields_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
func TestReadFieldsWithDefaults(t *testing.T) {
18-
defaults := map[string]interface{}{
18+
defaults := map[string]any{
1919
"one": "1",
2020
"two": int64(2),
2121
"three": uint64(3),
@@ -43,7 +43,7 @@ func TestReadFieldsWithDefaults(t *testing.T) {
4343
}
4444

4545
func TestReadFieldsWithoutDefaults(t *testing.T) {
46-
testReadFields(t, testStruct{}, map[string]interface{}{
46+
testReadFields(t, testStruct{}, map[string]any{
4747
"one": "",
4848
"three": uint64(0),
4949
"four": false,
@@ -53,7 +53,7 @@ func TestReadFieldsWithoutDefaults(t *testing.T) {
5353
})
5454
}
5555

56-
func testReadFields(t *testing.T, s testStruct, defaults map[string]interface{}) {
56+
func testReadFields(t *testing.T, s testStruct, defaults map[string]any) {
5757
root, _ := ReadFields(
5858
reflect.ValueOf(s),
5959
testDR(),

cmd/configschema/resolver_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestTypetoProjectPath_External(t *testing.T) {
6767
assert.Equal(t, "", dir)
6868
}
6969

70-
func testTypeToPackagePath(t *testing.T, v interface{}) string {
70+
func testTypeToPackagePath(t *testing.T, v any) string {
7171
packageDir, err := testDR().TypeToPackagePath(reflect.ValueOf(v).Type())
7272
require.NoError(t, err)
7373
return packageDir

cmd/mdatagen/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func templatize(tmplFile string, md metadata) *template.Template {
125125
template.
126126
New(filepath.Base(tmplFile)).
127127
Option("missingkey=error").
128-
Funcs(map[string]interface{}{
128+
Funcs(map[string]any{
129129
"publicVar": func(s string) (string, error) {
130130
return formatIdentifier(s, true)
131131
},

confmap/provider/s3provider/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (fmp *provider) Retrieve(ctx context.Context, uri string, _ confmap.Watcher
8282
// read config from response body
8383
dec := yaml.NewDecoder(resp.Body)
8484
defer resp.Body.Close()
85-
var conf map[string]interface{}
85+
var conf map[string]any
8686
err = dec.Decode(&conf)
8787
if err != nil {
8888
return nil, err

connector/exceptionsconnector/connector_metrics_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ func TestBuildKeyWithDimensions(t *testing.T) {
246246
for _, tc := range []struct {
247247
name string
248248
optionalDims []dimension
249-
resourceAttrMap map[string]interface{}
250-
spanAttrMap map[string]interface{}
249+
resourceAttrMap map[string]any
250+
spanAttrMap map[string]any
251251
wantKey string
252252
}{
253253
{
@@ -273,7 +273,7 @@ func TestBuildKeyWithDimensions(t *testing.T) {
273273
optionalDims: []dimension{
274274
{name: "foo"},
275275
},
276-
spanAttrMap: map[string]interface{}{
276+
spanAttrMap: map[string]any{
277277
"foo": 99,
278278
},
279279
wantKey: "ab\u0000c\u0000SPAN_KIND_UNSPECIFIED\u0000STATUS_CODE_UNSET\u000099",
@@ -283,7 +283,7 @@ func TestBuildKeyWithDimensions(t *testing.T) {
283283
optionalDims: []dimension{
284284
{name: "foo"},
285285
},
286-
resourceAttrMap: map[string]interface{}{
286+
resourceAttrMap: map[string]any{
287287
"foo": 99,
288288
},
289289
wantKey: "ab\u0000c\u0000SPAN_KIND_UNSPECIFIED\u0000STATUS_CODE_UNSET\u000099",
@@ -293,10 +293,10 @@ func TestBuildKeyWithDimensions(t *testing.T) {
293293
optionalDims: []dimension{
294294
{name: "foo"},
295295
},
296-
spanAttrMap: map[string]interface{}{
296+
spanAttrMap: map[string]any{
297297
"foo": 100,
298298
},
299-
resourceAttrMap: map[string]interface{}{
299+
resourceAttrMap: map[string]any{
300300
"foo": 99,
301301
},
302302
wantKey: "ab\u0000c\u0000SPAN_KIND_UNSPECIFIED\u0000STATUS_CODE_UNSET\u0000100",

connector/routingconnector/internal/common/functions.go

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

1313
func createRouteFunction[K any](_ ottl.FunctionContext, _ ottl.Arguments) (ottl.ExprFunc[K], error) {
14-
return func(context.Context, K) (interface{}, error) {
14+
return func(context.Context, K) (any, error) {
1515
return true, nil
1616
}, nil
1717
}

connector/spanmetricsconnector/connector_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,8 @@ func TestBuildKeyWithDimensions(t *testing.T) {
493493
for _, tc := range []struct {
494494
name string
495495
optionalDims []dimension
496-
resourceAttrMap map[string]interface{}
497-
spanAttrMap map[string]interface{}
496+
resourceAttrMap map[string]any
497+
spanAttrMap map[string]any
498498
wantKey string
499499
}{
500500
{
@@ -520,7 +520,7 @@ func TestBuildKeyWithDimensions(t *testing.T) {
520520
optionalDims: []dimension{
521521
{name: "foo"},
522522
},
523-
spanAttrMap: map[string]interface{}{
523+
spanAttrMap: map[string]any{
524524
"foo": 99,
525525
},
526526
wantKey: "ab\u0000c\u0000SPAN_KIND_UNSPECIFIED\u0000STATUS_CODE_UNSET\u000099",
@@ -530,7 +530,7 @@ func TestBuildKeyWithDimensions(t *testing.T) {
530530
optionalDims: []dimension{
531531
{name: "foo"},
532532
},
533-
resourceAttrMap: map[string]interface{}{
533+
resourceAttrMap: map[string]any{
534534
"foo": 99,
535535
},
536536
wantKey: "ab\u0000c\u0000SPAN_KIND_UNSPECIFIED\u0000STATUS_CODE_UNSET\u000099",
@@ -540,10 +540,10 @@ func TestBuildKeyWithDimensions(t *testing.T) {
540540
optionalDims: []dimension{
541541
{name: "foo"},
542542
},
543-
spanAttrMap: map[string]interface{}{
543+
spanAttrMap: map[string]any{
544544
"foo": 100,
545545
},
546-
resourceAttrMap: map[string]interface{}{
546+
resourceAttrMap: map[string]any{
547547
"foo": 99,
548548
},
549549
wantKey: "ab\u0000c\u0000SPAN_KIND_UNSPECIFIED\u0000STATUS_CODE_UNSET\u0000100",

0 commit comments

Comments
 (0)