chore: build with Go 1.26; use Go 1.25 features (#10570)

WaitGroup.Go and built-in gomaxprocs handling.

Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
Jakob Borg
2026-02-11 10:41:38 +00:00
committed by GitHub
parent 478d8a007d
commit dc2a77ab8e
44 changed files with 175 additions and 289 deletions
+6 -12
View File
@@ -605,15 +605,13 @@ func (s *service) dialDevices(ctx context.Context, now time.Time, cfg config.Con
dialWG.Wait()
dialCancel()
}()
for i := range queue {
for _, entry := range queue {
select {
case <-dialCtx.Done():
return
default:
}
dialWG.Add(1)
go func(entry dialQueueEntry) {
defer dialWG.Done()
dialWG.Go(func() {
conn, ok := s.dialParallel(dialCtx, entry.id, entry.targets, dialSemaphore)
if !ok {
return
@@ -630,7 +628,7 @@ func (s *service) dialDevices(ctx context.Context, now time.Time, cfg config.Con
}
}
numConnsMut.Unlock()
}(queue[i])
})
}
}
@@ -1118,12 +1116,8 @@ func (s *service) dialParallel(ctx context.Context, deviceID protocol.DeviceID,
wg := sync.WaitGroup{}
for _, tgt := range tgts {
sema.Take(1)
wg.Add(1)
go func(tgt dialTarget) {
defer func() {
wg.Done()
sema.Give(1)
}()
wg.Go(func() {
defer sema.Give(1)
conn, err := tgt.Dial(ctx)
if err == nil {
// Closes the connection on error
@@ -1136,7 +1130,7 @@ func (s *service) dialParallel(ctx context.Context, deviceID protocol.DeviceID,
l.Debugln("dialing", deviceID, tgt.uri, "success:", conn)
res <- conn
}
}(tgt)
})
}
// Spawn a routine which will unblock main routine in case we fail