Skip to content

Commit d71b46a

Browse files
committed
chore: upgrade to Go 1.26 and modernize codebase with latest idioms
- Bump go.mod to Go 1.26, update Dockerfile.dev and docs - Replace interface{} with any across all non-generated Go files - Use strings.CutPrefix instead of HasPrefix+TrimPrefix patterns - Use slices.SortFunc+cmp.Compare instead of sort.Slice - Use slices.Equal instead of reflect.DeepEqual in tests - Simplify C-style index loops to range expressions
1 parent 6c29344 commit d71b46a

117 files changed

Lines changed: 1057 additions & 1059 deletions

File tree

Some content is hidden

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

Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.16-stretch as base
1+
FROM golang:1.26-bookworm AS base
22
WORKDIR /build/
33
COPY . .
44
RUN ["make", "build-dev"]

agent/agent_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ var validRecipe = recipe.Recipe{
3434
Name: "test-extractor",
3535
},
3636
Processors: []recipe.PluginRecipe{
37-
{Name: "test-processor", Config: map[string]interface{}{
37+
{Name: "test-processor", Config: map[string]any{
3838
"proc-foo": "proc-bar",
3939
}},
4040
},
4141
Sinks: []recipe.PluginRecipe{
42-
{Name: "test-sink", Config: map[string]interface{}{
42+
{Name: "test-sink", Config: map[string]any{
4343
"url": "http://localhost:3000/data",
4444
}},
4545
},
@@ -919,14 +919,14 @@ func TestAgentRun(t *testing.T) {
919919
Source: recipe.PluginRecipe{
920920
Name: "application_yaml",
921921
Scope: "application-test",
922-
Config: map[string]interface{}{
922+
Config: map[string]any{
923923
"file": "../plugins/extractors/application_yaml/testdata/application.detailed.yaml",
924924
},
925925
},
926926
Processors: []recipe.PluginRecipe{
927927
{
928928
Name: "script",
929-
Config: map[string]interface{}{
929+
Config: map[string]any{
930930
"engine": "tengo",
931931
"script": heredoc.Doc(`
932932
text := import("text")
@@ -936,13 +936,13 @@ func TestAgentRun(t *testing.T) {
936936
},
937937
{
938938
Name: "labels",
939-
Config: map[string]interface{}{
939+
Config: map[string]any{
940940
"labels": map[string]string{"field_a": "1"},
941941
},
942942
},
943943
},
944944
Sinks: []recipe.PluginRecipe{
945-
{Name: "test-sink", Config: map[string]interface{}{}},
945+
{Name: "test-sink", Config: map[string]any{}},
946946
},
947947
})
948948
assert.NoError(t, run.Error)
@@ -953,13 +953,13 @@ func TestAgentRun(t *testing.T) {
953953
Type: "application",
954954
Description: "My amazing project",
955955
Properties: func() *structpb.Struct {
956-
s, _ := structpb.NewStruct(map[string]interface{}{
956+
s, _ := structpb.NewStruct(map[string]any{
957957
"id": "test-id",
958958
"version": "c23sdf6",
959959
"url": "http://company.com/myteam/test",
960960
"create_time": "2006-01-02T15:04:05Z",
961961
"update_time": "2006-01-02T15:04:05Z",
962-
"labels": map[string]interface{}{"field_a": "1", "x": "y"},
962+
"labels": map[string]any{"field_a": "1", "x": "y"},
963963
})
964964
return s
965965
}(),
@@ -982,13 +982,13 @@ func TestAgentRun(t *testing.T) {
982982
Source: recipe.PluginRecipe{
983983
Name: "application_yaml",
984984
Scope: "application-test",
985-
Config: map[string]interface{}{
985+
Config: map[string]any{
986986
"file": "../plugins/extractors/application_yaml/testdata/application.detailed.yaml",
987987
},
988988
},
989989
Sinks: []recipe.PluginRecipe{{
990990
Name: "file",
991-
Config: map[string]interface{}{
991+
Config: map[string]any{
992992
"path": "./application_yaml-sink[yaml].out",
993993
"format": "yaml",
994994
"overwrite": true,
@@ -1081,22 +1081,22 @@ func TestValidate(t *testing.T) {
10811081
Name: "sample",
10821082
Source: recipe.PluginRecipe{
10831083
Name: "test-extractor",
1084-
Config: map[string]interface{}{
1084+
Config: map[string]any{
10851085
"proc-foo": "proc-bar",
10861086
},
10871087
},
10881088
Processors: []recipe.PluginRecipe{
10891089
{
10901090
Name: "test-processor",
1091-
Config: map[string]interface{}{
1091+
Config: map[string]any{
10921092
"proc-foo": "proc-bar",
10931093
},
10941094
},
10951095
},
10961096
Sinks: []recipe.PluginRecipe{
10971097
{
10981098
Name: "test-sink",
1099-
Config: map[string]interface{}{
1099+
Config: map[string]any{
11001100
"url": "http://localhost:3000/data",
11011101
},
11021102
},

docs/docs/guides/0_installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ $ docker run --rm raystack/meteor meteor list extractors
4040

4141
## Build from source
4242

43-
Requires you to have `git` and `golang (version 1.16 or above)` installed.
43+
Requires you to have `git` and `golang (version 1.26 or above)` installed.
4444

4545
```bash
4646
#clone repo

generator/recipe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type TemplateData struct {
2626
Processors map[string]string
2727
}
2828

29-
var TemplateFuncs = map[string]interface{}{
29+
var TemplateFuncs = map[string]any{
3030
"indent": indent,
3131
"rawfmt": rawfmt,
3232
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/raystack/meteor
22

3-
go 1.25.0
3+
go 1.26.0
44

55
require (
66
cloud.google.com/go/bigquery v1.74.0

metrics/otelgrpc/otelgrpc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (m *Monitor) RecordStream(ctx context.Context, start time.Time, method stri
105105
func (m *Monitor) UnaryClientInterceptor() grpc.UnaryClientInterceptor {
106106
return func(ctx context.Context,
107107
method string,
108-
req, reply interface{},
108+
req, reply any,
109109
cc *grpc.ClientConn,
110110
invoker grpc.UnaryInvoker,
111111
opts ...grpc.CallOption,

metrics/otelgrpc/otelgrpc_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package otelgrpc_test
33
import (
44
"context"
55
"errors"
6-
"reflect"
6+
"slices"
77
"testing"
88
"time"
99

@@ -74,7 +74,7 @@ func Test_parseFullMethod(t *testing.T) {
7474
}
7575
for _, tt := range tests {
7676
t.Run(tt.name, func(t *testing.T) {
77-
if got := otelgrpc.ParseFullMethod(tt.args.fullMethod); !reflect.DeepEqual(got, tt.want) {
77+
if got := otelgrpc.ParseFullMethod(tt.args.fullMethod); !slices.Equal(got, tt.want) {
7878
t.Errorf("parseFullMethod() = %v, want %v", got, tt.want)
7979
}
8080
})

models/util.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func NewURN(service, scope, kind, id string) string {
2020
// NewEntity creates an entity with properties from a map.
2121
// Values in props are sanitized to be compatible with structpb.NewStruct:
2222
// map[string]string is converted to map[string]interface{}, etc.
23-
func NewEntity(urn, typ, name, source string, props map[string]interface{}) *meteorv1beta1.Entity {
23+
func NewEntity(urn, typ, name, source string, props map[string]any) *meteorv1beta1.Entity {
2424
var properties *structpb.Struct
2525
if len(props) > 0 {
2626
sanitized := sanitizeMap(props)
@@ -82,7 +82,7 @@ func RecordToJSON(r Record) ([]byte, error) {
8282
edgesJSON = append(edgesJSON, b)
8383
}
8484

85-
result := map[string]interface{}{
85+
result := map[string]any{
8686
"entity": json.RawMessage(entityJSON),
8787
}
8888
if len(edgesJSON) > 0 {
@@ -94,38 +94,38 @@ func RecordToJSON(r Record) ([]byte, error) {
9494

9595
// sanitizeMap recursively converts typed maps (e.g., map[string]string) to
9696
// map[string]interface{} so they are compatible with structpb.NewStruct.
97-
func sanitizeMap(m map[string]interface{}) map[string]interface{} {
98-
out := make(map[string]interface{}, len(m))
97+
func sanitizeMap(m map[string]any) map[string]any {
98+
out := make(map[string]any, len(m))
9999
for k, v := range m {
100100
out[k] = sanitizeValue(v)
101101
}
102102
return out
103103
}
104104

105-
func sanitizeValue(v interface{}) interface{} {
105+
func sanitizeValue(v any) any {
106106
switch val := v.(type) {
107107
case map[string]string:
108-
out := make(map[string]interface{}, len(val))
108+
out := make(map[string]any, len(val))
109109
for k, v := range val {
110110
out[k] = v
111111
}
112112
return out
113-
case map[string]interface{}:
113+
case map[string]any:
114114
return sanitizeMap(val)
115-
case []interface{}:
116-
out := make([]interface{}, len(val))
115+
case []any:
116+
out := make([]any, len(val))
117117
for i, item := range val {
118118
out[i] = sanitizeValue(item)
119119
}
120120
return out
121-
case []map[string]interface{}:
122-
out := make([]interface{}, len(val))
121+
case []map[string]any:
122+
out := make([]any, len(val))
123123
for i, item := range val {
124124
out[i] = sanitizeMap(item)
125125
}
126126
return out
127127
case []string:
128-
out := make([]interface{}, len(val))
128+
out := make([]any, len(val))
129129
for i, item := range val {
130130
out[i] = item
131131
}

models/util_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ func TestNewURN(t *testing.T) {
3737
}
3838

3939
func TestNewEntity(t *testing.T) {
40-
entity := models.NewEntity("urn:test:s:table:t1", "table", "t1", "test", map[string]interface{}{
41-
"columns": []interface{}{"id", "name"},
40+
entity := models.NewEntity("urn:test:s:table:t1", "table", "t1", "test", map[string]any{
41+
"columns": []any{"id", "name"},
4242
})
4343
assert.Equal(t, "urn:test:s:table:t1", entity.GetUrn())
4444
assert.Equal(t, "table", entity.GetType())

plugins/base_extractor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type BaseExtractor struct {
77
BasePlugin
88
}
99

10-
func NewBaseExtractor(info Info, configRef interface{}) BaseExtractor {
10+
func NewBaseExtractor(info Info, configRef any) BaseExtractor {
1111
return BaseExtractor{
1212
BasePlugin: NewBasePlugin(info, configRef),
1313
}

0 commit comments

Comments
 (0)