Skip to content

Commit 7609882

Browse files
authored
Update to Go 1.26, golangci-lint 2.10.1 (#3946)
[Go 1.26](https://go.dev/doc/go1.26) has three changes of note: - new(var) turns a value into a pointer, replacing our shared.Ptr. Implementing - Self-referential generics are allowed. This would apply to our RecordItems/PgItems UpdateIfNotExists but also comes with noisy changes across many callsites and it's only really used for the CDC store that we're looking to rip out. Keeping as is - fmt.Errorf(constant_string) is now performant but we'd also need to reconfigure linters. Moving to [DBI-529: Use golang 1.26's fmt.Errorf instead of errors.New](https://linear.app/clickhouse/issue/DBI-529/use-golang-126s-fmterrorf-instead-of-errorsnew) Needs a golangci-lint bump to lint successfully
1 parent 227a225 commit 7609882

23 files changed

Lines changed: 40 additions & 59 deletions

File tree

.github/workflows/golang-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ jobs:
2929
- name: golangci-lint flow
3030
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9
3131
with:
32-
version: v2.9.0
32+
version: v2.10.1
3333
working-directory: ./flow
3434
args: --timeout=10m
3535
- name: golangci-lint e2e_cleanup
3636
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9
3737
with:
38-
version: v2.9.0
38+
version: v2.10.1
3939
working-directory: ./e2e_cleanup
4040
args: --timeout=10m

e2e_cleanup/go.mod

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

3-
go 1.25.0
3+
go 1.26.0
44

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

flow/activities/flowable.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func (a *FlowableActivity) SyncFlow(
306306
var normalizeWaiting atomic.Bool
307307
var syncingBatchID atomic.Int64
308308
var syncState atomic.Pointer[string]
309-
syncState.Store(shared.Ptr("setup"))
309+
syncState.Store(new("setup"))
310310
shutdown := common.HeartbeatRoutine(ctx, func() string {
311311
// Must load Waiting after BatchID to avoid race saying we're waiting on currently processing batch
312312
sBatchID := syncingBatchID.Load()
@@ -400,7 +400,7 @@ func (a *FlowableActivity) SyncFlow(
400400
break
401401
}
402402
logger.Error("failed to sync records", slog.Any("error", syncErr))
403-
syncState.Store(shared.Ptr("cleanup"))
403+
syncState.Store(new("cleanup"))
404404
close(syncDone)
405405
normRequests.Close()
406406
normResponses.Close()
@@ -419,7 +419,7 @@ func (a *FlowableActivity) SyncFlow(
419419
}
420420
}
421421

422-
syncState.Store(shared.Ptr("cleanup"))
422+
syncState.Store(new("cleanup"))
423423
close(syncDone)
424424
normRequests.Close()
425425
normResponses.Close()

flow/activities/flowable_core.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func syncCore[TPull connectors.CDCPullConnectorCore, TSync connectors.CDCSyncCon
194194
}
195195

196196
startTime := time.Now()
197-
syncState.Store(shared.Ptr("syncing"))
197+
syncState.Store(new("syncing"))
198198
errGroup, errCtx := errgroup.WithContext(ctx)
199199
errGroup.Go(func() error {
200200
return pull(srcConn, errCtx, a.CatalogPool, a.OtelManager, &model.PullRecordsRequest[Items]{
@@ -235,7 +235,7 @@ func syncCore[TPull connectors.CDCPullConnectorCore, TSync connectors.CDCSyncCon
235235
}
236236
defer dstClose(ctx)
237237

238-
syncState.Store(shared.Ptr("updating schema"))
238+
syncState.Store(new("updating schema"))
239239
if err := dstConn.ReplayTableSchemaDeltas(
240240
ctx, config.Env, flowName, options.TableMappings, recordBatchSync.SchemaDeltas, config.Flags,
241241
); err != nil {
@@ -319,7 +319,7 @@ func syncCore[TPull connectors.CDCPullConnectorCore, TSync connectors.CDCSyncCon
319319
}
320320
return nil, fmt.Errorf("[cdc] failed to pull records: %w", err)
321321
}
322-
syncState.Store(shared.Ptr("bookkeeping"))
322+
syncState.Store(new("bookkeeping"))
323323

324324
syncDuration := time.Since(syncStartTime)
325325
lastCheckpoint := recordBatchSync.GetLastCheckpoint()
@@ -350,13 +350,13 @@ func syncCore[TPull connectors.CDCPullConnectorCore, TSync connectors.CDCSyncCon
350350

351351
a.OtelManager.Metrics.CurrentBatchIdGauge.Record(ctx, res.CurrentSyncBatchID)
352352

353-
syncState.Store(shared.Ptr("updating schema"))
353+
syncState.Store(new("updating schema"))
354354
if err := a.applySchemaDeltas(ctx, config, res.TableSchemaDeltas); err != nil {
355355
return nil, err
356356
}
357357

358358
if recordBatchSync.NeedsNormalize() {
359-
syncState.Store(shared.Ptr("normalizing"))
359+
syncState.Store(new("normalizing"))
360360
normRequests.Update(res.CurrentSyncBatchID)
361361
normWaitThreshold := res.CurrentSyncBatchID - normBufferSize
362362
if normResponses.Load() <= normWaitThreshold {

flow/alerting/slack_alert_sender.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func (s *SlackAlertSender) getOpenConnectionsAlertThreshold() uint32 {
2626
}
2727

2828
type slackAlertConfig struct {
29-
AuthToken string `json:"auth_token"`
29+
AuthToken string `json:"auth_token"` //nolint:gosec // G117: credential field by design, encrypted outside
3030
ChannelIDs []string `json:"channel_ids"`
3131
Members []string `json:"members"`
3232
SlotLagMBAlertThreshold uint32 `json:"slot_lag_mb_alert_threshold"`

flow/cmd/maintenance.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"os"
1010
"strings"
1111

12-
"github.com/aws/smithy-go/ptr"
1312
"go.temporal.io/sdk/client"
1413
"google.golang.org/grpc"
1514
"google.golang.org/grpc/credentials"
@@ -73,7 +72,7 @@ func MaintenanceMain(ctx context.Context, args *MaintenanceCLIParams) error {
7372
slog.InfoContext(ctx, "Assuming maintenance workflows were skipped")
7473
return WriteMaintenanceOutputToCatalog(ctx, StartMaintenanceResult{
7574
Skipped: true,
76-
SkippedReason: ptr.String("Assumed skipped by CLI Flag"),
75+
SkippedReason: new("Assumed skipped by CLI Flag"),
7776
CLIVersion: internal.PeerDBVersionShaShort(),
7877
})
7978
}
@@ -143,7 +142,7 @@ func skipStartMaintenanceIfNeeded(ctx context.Context, args *MaintenanceCLIParam
143142
slog.InfoContext(ctx, "Skipping maintenance workflow due to missing k8s service", "service", args.SkipIfK8sServiceMissing)
144143
return true, WriteMaintenanceOutputToCatalog(ctx, StartMaintenanceResult{
145144
Skipped: true,
146-
SkippedReason: ptr.String(fmt.Sprintf("K8s service %s missing", args.SkipIfK8sServiceMissing)),
145+
SkippedReason: new(fmt.Sprintf("K8s service %s missing", args.SkipIfK8sServiceMissing)),
147146
CLIVersion: internal.PeerDBVersionShaShort(),
148147
CLIDeployVersion: internal.PeerDBDeploymentVersion(),
149148
})
@@ -189,11 +188,11 @@ func skipStartMaintenanceIfNeeded(ctx context.Context, args *MaintenanceCLIParam
189188
"deployApiVersion", version.DeploymentVersion, "cliDeployVersion", internal.PeerDBDeploymentVersion())
190189
return true, WriteMaintenanceOutputToCatalog(ctx, StartMaintenanceResult{
191190
Skipped: true,
192-
SkippedReason: ptr.String("Version Mismatch: " + strings.Join(skippedReasons, ", ")),
191+
SkippedReason: new("Version Mismatch: " + strings.Join(skippedReasons, ", ")),
193192
CLIVersion: internal.PeerDBVersionShaShort(),
194193
CLIDeployVersion: internal.PeerDBDeploymentVersion(),
195194
APIVersion: version.Version,
196-
APIDeployVersion: ptr.ToString(version.DeploymentVersion),
195+
APIDeployVersion: shared.Val(version.DeploymentVersion),
197196
})
198197
}
199198
}
@@ -208,7 +207,7 @@ func skipStartMaintenanceIfNeeded(ctx context.Context, args *MaintenanceCLIParam
208207
slog.InfoContext(ctx, "Skipping maintenance workflow due to no mirrors")
209208
return true, WriteMaintenanceOutputToCatalog(ctx, StartMaintenanceResult{
210209
Skipped: true,
211-
SkippedReason: ptr.String("No mirrors found"),
210+
SkippedReason: new("No mirrors found"),
212211
})
213212
}
214213
}

flow/cmd/settings.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ func (h *FlowRequestHandler) GetDynamicSettings(
3535
if _, err := pgx.ForEachRow(rows, []any{&name, &value}, func() error {
3636
if idx, ok := internal.DynamicIndex[name]; ok {
3737
settings[idx] = proto.CloneOf(settings[idx])
38-
newValue := value // create a new string reference as value can be overwritten by the next iteration.
39-
settings[idx].Value = &newValue
38+
settings[idx].Value = new(value) // create a new string reference as value can be overwritten by the next iteration.
4039
}
4140
return nil
4241
}); err != nil {

flow/connectors/mysql/rds_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"os"
55
"testing"
66

7-
"github.com/aws/smithy-go/ptr"
87
"github.com/stretchr/testify/require"
98

109
"github.com/PeerDB-io/peerdb/flow/generated/protos"
@@ -29,7 +28,7 @@ func TestAwsRDSIAMAuthConnectForMYSQL(t *testing.T) {
2928
AuthConfig: &protos.AwsAuthenticationConfig_Role{
3029
Role: &protos.AWSAuthAssumeRoleConfig{
3130
AssumeRoleArn: os.Getenv("FLOW_TESTS_RDS_IAM_AUTH_ASSUME_ROLE"),
32-
ChainedRoleArn: ptr.String(os.Getenv("FLOW_TESTS_RDS_IAM_AUTH_CHAINED_ROLE")),
31+
ChainedRoleArn: new(os.Getenv("FLOW_TESTS_RDS_IAM_AUTH_CHAINED_ROLE")),
3332
},
3433
},
3534
},
@@ -60,7 +59,7 @@ func TestAwsRDSIAMAuthConnectForMYSQLViaProxy(t *testing.T) {
6059
AuthConfig: &protos.AwsAuthenticationConfig_Role{
6160
Role: &protos.AWSAuthAssumeRoleConfig{
6261
AssumeRoleArn: os.Getenv("FLOW_TESTS_RDS_IAM_AUTH_ASSUME_ROLE"),
63-
ChainedRoleArn: ptr.String(os.Getenv("FLOW_TESTS_RDS_IAM_AUTH_CHAINED_ROLE")),
62+
ChainedRoleArn: new(os.Getenv("FLOW_TESTS_RDS_IAM_AUTH_CHAINED_ROLE")),
6463
},
6564
},
6665
},

flow/connectors/postgres/rds_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"os"
55
"testing"
66

7-
"github.com/aws/smithy-go/ptr"
87
"github.com/stretchr/testify/require"
98

109
"github.com/PeerDB-io/peerdb/flow/generated/protos"
@@ -31,7 +30,7 @@ func TestAwsRDSIAMAuthConnectForPostgres(t *testing.T) {
3130
AuthConfig: &protos.AwsAuthenticationConfig_Role{
3231
Role: &protos.AWSAuthAssumeRoleConfig{
3332
AssumeRoleArn: os.Getenv("FLOW_TESTS_RDS_IAM_AUTH_ASSUME_ROLE"),
34-
ChainedRoleArn: ptr.String(os.Getenv("FLOW_TESTS_RDS_IAM_AUTH_CHAINED_ROLE")),
33+
ChainedRoleArn: new(os.Getenv("FLOW_TESTS_RDS_IAM_AUTH_CHAINED_ROLE")),
3534
},
3635
},
3736
},
@@ -74,7 +73,7 @@ func TestAwsRDSIAMAuthConnectForPostgresViaProxy(t *testing.T) {
7473
AuthConfig: &protos.AwsAuthenticationConfig_Role{
7574
Role: &protos.AWSAuthAssumeRoleConfig{
7675
AssumeRoleArn: os.Getenv("FLOW_TESTS_RDS_IAM_AUTH_ASSUME_ROLE"),
77-
ChainedRoleArn: ptr.String(os.Getenv("FLOW_TESTS_RDS_IAM_AUTH_CHAINED_ROLE")),
76+
ChainedRoleArn: new(os.Getenv("FLOW_TESTS_RDS_IAM_AUTH_CHAINED_ROLE")),
7877
},
7978
},
8079
},

flow/connectors/snowflake/snowflake.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"sync/atomic"
1212
"time"
1313

14-
"github.com/aws/smithy-go/ptr"
1514
"github.com/jackc/pgx/v5/pgtype"
1615
"github.com/snowflakedb/gosnowflake"
1716
"go.temporal.io/sdk/log"
@@ -92,7 +91,7 @@ func NewSnowflakeConnector(
9291
}
9392

9493
additionalParams := make(map[string]*string)
95-
additionalParams["CLIENT_SESSION_KEEP_ALIVE"] = ptr.String("true")
94+
additionalParams["CLIENT_SESSION_KEEP_ALIVE"] = new("true")
9695

9796
snowflakeConfig := gosnowflake.Config{
9897
Account: snowflakeProtoConfig.AccountId,

0 commit comments

Comments
 (0)