diff --git a/.tool-versions b/.tool-versions index 4d3e4fa38c..f3e91d94ea 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,5 +1,5 @@ -golang 1.24.5 +golang 1.25.3 protoc 29.3 protoc-gen-go-grpc 1.3.0 -golangci-lint 2.2.2 +golangci-lint 2.4.0 mockery 2.53.3 diff --git a/go.mod b/go.mod index 74bece9852..35104ba030 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/smartcontractkit/chainlink-common -go 1.24.5 +go 1.25.3 require ( github.com/Masterminds/semver/v3 v3.4.0 diff --git a/pkg/loop/internal/net/broker.go b/pkg/loop/internal/net/broker.go index b7b8f47b41..4a04e5d27b 100644 --- a/pkg/loop/internal/net/broker.go +++ b/pkg/loop/internal/net/broker.go @@ -112,25 +112,21 @@ func (b *BrokerExt) Serve(name string, server *grpc.Server, deps ...Resource) (u } var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { defer b.CloseAll(deps...) if err := server.Serve(lis); err != nil { b.Logger.Errorw(fmt.Sprintf("Failed to serve %s on connection %d", name, id), "err", err) } - }() + }) done := make(chan struct{}) - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { select { case <-b.StopCh: server.Stop() case <-done: } - }() + }) return id, Resource{fnCloser(sync.OnceFunc(func() { server.Stop() diff --git a/pkg/services/service.go b/pkg/services/service.go index 9d474631bc..fc1dfc31b8 100644 --- a/pkg/services/service.go +++ b/pkg/services/service.go @@ -66,25 +66,21 @@ type Engine struct { // defer span.End() // }) func (e *Engine) Go(fn func(context.Context)) { - e.wg.Add(1) - go func() { - defer e.wg.Done() + e.wg.Go(func() { ctx, cancel := e.StopChan.NewCtx() defer cancel() fn(ctx) - }() + }) } // GoCtx is like Go but passes through ctx. // Use context.WithoutCancel if the function should continue running. func (e *Engine) GoCtx(ctx context.Context, fn func(context.Context)) { - e.wg.Add(1) - go func() { - defer e.wg.Done() + e.wg.Go(func() { ctx, cancel := e.StopChan.Ctx(ctx) defer cancel() fn(ctx) - }() + }) } // GoTick is like Go but calls fn for each tick. diff --git a/pkg/sqlutil/sqltest/txdb_test.go b/pkg/sqlutil/sqltest/txdb_test.go index 9adb3fc3fa..eeba5ee6f7 100644 --- a/pkg/sqlutil/sqltest/txdb_test.go +++ b/pkg/sqlutil/sqltest/txdb_test.go @@ -22,12 +22,10 @@ func TestTxDBDriver(t *testing.T) { t.Run("Make sure sql.Register() can be called concurrently without racing", func(t *testing.T) { wg := sync.WaitGroup{} for range 10 { - wg.Add(1) - go func() { + wg.Go(func() { err := RegisterTxDB(pg.DriverInMemoryPostgres) require.NoError(t, err) - wg.Done() - }() + }) } wg.Wait() drivers := sql.Drivers() diff --git a/pkg/types/gateway/round_robin_selector_test.go b/pkg/types/gateway/round_robin_selector_test.go index a783c0e7aa..aa737f78d5 100644 --- a/pkg/types/gateway/round_robin_selector_test.go +++ b/pkg/types/gateway/round_robin_selector_test.go @@ -72,16 +72,14 @@ func TestRoundRobinSelector_Concurrency(t *testing.T) { results := make(chan string, numRequests) for range numRequests { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { gw, err := rr.NextGateway() if err != nil { t.Errorf("unexpected error: %v", err) return } results <- gw - }() + }) } wg.Wait() diff --git a/pkg/utils/subprocesses.go b/pkg/utils/subprocesses.go index 6cf127cfe4..d43a87346a 100644 --- a/pkg/utils/subprocesses.go +++ b/pkg/utils/subprocesses.go @@ -38,9 +38,7 @@ func (s *Subprocesses) Wait() { // Go calls the given function in a new goroutine. func (s *Subprocesses) Go(f func()) { - s.wg.Add(1) - go func() { - defer s.wg.Done() + s.wg.Go(func() { f() - }() + }) } diff --git a/pkg/workflows/wasm/host/module.go b/pkg/workflows/wasm/host/module.go index ade6d044d4..7bf980beff 100644 --- a/pkg/workflows/wasm/host/module.go +++ b/pkg/workflows/wasm/host/module.go @@ -404,10 +404,7 @@ func linkLegacyDAG(m *module, store *wasmtime.Store, exec *execution[*wasmdagpb. } func (m *module) Start() { - m.wg.Add(1) - go func() { - defer m.wg.Done() - + m.wg.Go(func() { ticker := time.NewTicker(m.cfg.TickInterval) for { select { @@ -417,7 +414,7 @@ func (m *module) Start() { m.engine.IncrementEpoch() } } - }() + }) } func (m *module) Close() {