apply go fix for Go 1.26

This applies the `go fix` recommendations for go1.26
This commit is contained in:
Wade Simmons
2026-09-01 11:39:02 -04:00
parent dd8f660c0a
commit ae0fa0f2af
4 changed files with 8 additions and 18 deletions
+2 -8
View File
@@ -79,10 +79,7 @@ func (b *Bits) clearRange(startPos, count uint64) uint64 {
// handle the potential partial word before pos becomes u64 aligned // handle the potential partial word before pos becomes u64 aligned
word := pos >> 6 word := pos >> 6
bit := pos & 63 bit := pos & 63
take := uint64(64) - bit take := min(uint64(64)-bit, remaining)
if take > remaining {
take = remaining
}
if take > b.length-pos { if take > b.length-pos {
take = b.length - pos take = b.length - pos
} }
@@ -189,10 +186,7 @@ func (b *Bits) Update(l *slog.Logger, i uint64) bool {
func (b *Bits) updateSlow(l *slog.Logger, i uint64) bool { func (b *Bits) updateSlow(l *slog.Logger, i uint64) bool {
// If i is a jump, adjust the window, record lost, update current, and return true // If i is a jump, adjust the window, record lost, update current, and return true
if i > b.current { if i > b.current {
end := i end := min(i, b.current+b.length)
if end > b.current+b.length {
end = b.current + b.length
}
count := end - b.current count := end - b.current
startPos := (b.current + 1) & b.lengthMask startPos := (b.current + 1) & b.lengthMask
+1 -1
View File
@@ -97,7 +97,7 @@ func TestConnectionState_NextMessageCounter(t *testing.T) {
assert.Equal(t, RejectAfterMessages, cs.messageCounter.Load()) assert.Equal(t, RejectAfterMessages, cs.messageCounter.Load())
// Continued send attempts stay refused and the counter never wraps // Continued send attempts stay refused and the counter never wraps
for i := 0; i < 10; i++ { for range 10 {
_, ok = cs.NextMessageCounter() _, ok = cs.NextMessageCounter()
assert.False(t, ok) assert.False(t, ok)
} }
+1 -1
View File
@@ -247,7 +247,7 @@ func TestControl_ConcurrentStopAndStart(t *testing.T) {
c, _, _ := newReadyControl(t) c, _, _ := newReadyControl(t)
var wg sync.WaitGroup var wg sync.WaitGroup
for i := 0; i < 2; i++ { for range 2 {
wg.Go(func() { c.Stop() }) wg.Go(func() { c.Stop() })
} }
wg.Go(func() { _ = c.Start() }) wg.Go(func() { _ = c.Start() })
+4 -8
View File
@@ -1,21 +1,19 @@
package nebula package nebula
import ( import (
"context"
"testing" "testing"
"time" "time"
) )
func TestScheduler_PooledReuse(t *testing.T) { func TestScheduler_PooledReuse(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background()) ctx := t.Context()
defer cancel()
s := NewScheduler[int](16) s := NewScheduler[int](16)
delivered := make(chan int, 256) delivered := make(chan int, 256)
go s.Run(ctx, func(item int) { delivered <- item }) go s.Run(ctx, func(item int) { delivered <- item })
const N = 100 const N = 100
for i := 0; i < N; i++ { for i := range N {
s.Schedule(ctx, i, time.Millisecond) s.Schedule(ctx, i, time.Millisecond)
} }
@@ -34,8 +32,7 @@ func TestScheduler_PooledReuse(t *testing.T) {
// BenchmarkScheduler_Schedule reports allocations per Schedule call. // BenchmarkScheduler_Schedule reports allocations per Schedule call.
// In steady state the Scheduler's sync.Pool means we should see zero allocs per op once the pool warms up. // In steady state the Scheduler's sync.Pool means we should see zero allocs per op once the pool warms up.
func BenchmarkScheduler_Schedule(b *testing.B) { func BenchmarkScheduler_Schedule(b *testing.B) {
ctx, cancel := context.WithCancel(context.Background()) ctx := b.Context()
defer cancel()
s := NewScheduler[int](b.N) s := NewScheduler[int](b.N)
go s.Run(ctx, func(int) {}) go s.Run(ctx, func(int) {})
@@ -51,8 +48,7 @@ func BenchmarkScheduler_Schedule(b *testing.B) {
// What we'd pay per Schedule if Punchy called time.AfterFunc directly without the pooled Scheduler. // What we'd pay per Schedule if Punchy called time.AfterFunc directly without the pooled Scheduler.
// Allocates a *time.Timer plus a closure each call. // Allocates a *time.Timer plus a closure each call.
func BenchmarkBareAfterFunc(b *testing.B) { func BenchmarkBareAfterFunc(b *testing.B) {
ctx, cancel := context.WithCancel(context.Background()) ctx := b.Context()
defer cancel()
queue := make(chan int, b.N) queue := make(chan int, b.N)
go func() { go func() {