Go 1.27.1, and the code it can say more simply

Modules declare go 1.27.1 and the build images follow. go fix applied the
modernizers: any, WaitGroup.Go, range over int, and a promoted-field key in
a struct literal. omitzero is not applied, since it changes what the JSON
says.

Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
2026-09-16 19:46:08 -07:00
co-authored by Hanzo Dev
parent c42c0bec03
commit adf4508709
15 changed files with 29 additions and 35 deletions
+4 -4
View File
@@ -39,7 +39,7 @@ func TestBoundedQueue(t *testing.T) {
require.Zero(b.Len())
// Fill the queue
for i := 0; i < maxSize; i++ {
for i := range maxSize {
b.Push(i)
require.Equal(i+1, b.Len())
got, ok := b.Peek()
@@ -55,7 +55,7 @@ func TestBoundedQueue(t *testing.T) {
// Queue is [0, 1, 2]
// Empty the queue
for i := 0; i < maxSize; i++ {
for i := range maxSize {
got, ok := b.Pop()
require.True(ok)
require.Equal(i, got)
@@ -75,7 +75,7 @@ func TestBoundedQueue(t *testing.T) {
require.Empty(b.List())
// Fill the queue again
for i := 0; i < maxSize; i++ {
for i := range maxSize {
b.Push(i)
require.Equal(i+1, b.Len())
}
@@ -120,7 +120,7 @@ func TestBoundedQueue(t *testing.T) {
}
// Empty the queue
for i := 0; i < maxSize; i++ {
for i := range maxSize {
got, ok := b.Pop()
require.True(ok)
require.Equal(i+3, got)
+2 -4
View File
@@ -70,11 +70,9 @@ func TestUnboundedBlockingDequePop(t *testing.T) {
)
wg := &sync.WaitGroup{}
wg.Add(1)
go func() {
wg.Go(func() {
gotCh, gotOk = deque.PopLeft()
wg.Done()
}()
})
ok = deque.PushRight(2)
require.True(ok)
+1 -1
View File
@@ -653,7 +653,7 @@ func FuzzUnboundedSliceDeque(f *testing.F) {
require.Equal(n, list[i])
}
for i := 0; i < len(input); i++ {
for i := range input {
_, _ = b.PopLeft()
list = b.List()
if i == len(input)-1 {
+3 -3
View File
@@ -6,11 +6,11 @@ package container
// List interface for sequential data
type List[T any] interface {
Front() interface{}
Back() interface{}
Front() any
Back() any
PushFront(T)
PushBack(T)
Remove(interface{})
Remove(any)
Len() int
}
+1 -1
View File
@@ -1,6 +1,6 @@
module github.com/luxfi/container
go 1.26.4
go 1.27.1
require (
github.com/google/btree v1.1.3
+2 -4
View File
@@ -21,10 +21,8 @@ func MapValues[K comparable, V any](m Map[K, V]) []V {
func NewMap[K comparable, V any](less func(a, b V) bool) Map[K, V] {
return Map[K, V]{
queue: &indexedQueue[K, V]{
queue: queue[entry[K, V]]{
less: func(a, b entry[K, V]) bool {
return less(a.v, b.v)
},
less: func(a, b entry[K, V]) bool {
return less(a.v, b.v)
},
index: make(map[K]int),
},
+2 -4
View File
@@ -29,9 +29,7 @@ func FromTree[T any](btree *btree.BTreeG[T]) Iterator[T] {
next: make(chan T),
release: make(chan struct{}),
}
it.wg.Add(1)
go func() {
defer it.wg.Done()
it.wg.Go(func() {
btree.Ascend(func(i T) bool {
select {
case it.next <- i:
@@ -41,7 +39,7 @@ func FromTree[T any](btree *btree.BTreeG[T]) Iterator[T] {
}
})
close(it.next)
}()
})
return it
}
+2 -2
View File
@@ -40,7 +40,7 @@ func TestList_PushBack(t *testing.T) {
l := NewList[int]()
for i := 0; i < 5; i++ {
for i := range 5 {
l.PushBack(&ListElement[int]{
Value: i,
})
@@ -72,7 +72,7 @@ func TestList_PushFront(t *testing.T) {
l := NewList[int]()
for i := 0; i < 5; i++ {
for i := range 5 {
l.PushFront(&ListElement[int]{
Value: i,
})
+5 -5
View File
@@ -19,7 +19,7 @@ type ObjectPool[T any] struct {
func NewObjectPool[T any](new func() T, reset func(T)) *ObjectPool[T] {
return &ObjectPool[T]{
pool: sync.Pool{
New: func() interface{} {
New: func() any {
return new()
},
},
@@ -51,7 +51,7 @@ type ByteSlicePool struct {
func NewByteSlicePool(size int) *ByteSlicePool {
return &ByteSlicePool{
pool: sync.Pool{
New: func() interface{} {
New: func() any {
return make([]byte, size)
},
},
@@ -80,7 +80,7 @@ type BufferPool struct {
func NewBufferPool() *BufferPool {
return &BufferPool{
pool: sync.Pool{
New: func() interface{} {
New: func() any {
return new(bytes.Buffer)
},
},
@@ -112,7 +112,7 @@ type MapPool[K comparable, V any] struct {
func NewMapPool[K comparable, V any]() *MapPool[K, V] {
return &MapPool[K, V]{
pool: sync.Pool{
New: func() interface{} {
New: func() any {
return make(map[K]V)
},
},
@@ -142,7 +142,7 @@ type SlicePool[T any] struct {
func NewSlicePool[T any](initialCap int) *SlicePool[T] {
return &SlicePool[T]{
pool: sync.Pool{
New: func() interface{} {
New: func() any {
return make([]T, 0, initialCap)
},
},
+1 -1
View File
@@ -40,7 +40,7 @@ func (s *uniformReplacer) Sample(count int) ([]uint64, bool) {
s.Reset()
results := make([]uint64, count)
for i := 0; i < count; i++ {
for i := range count {
ret, hasNext := s.Next()
if !hasNext {
return nil, false
+1 -1
View File
@@ -27,7 +27,7 @@ func (s *uniformResample) Sample(count int) ([]uint64, bool) {
s.Reset()
results := make([]uint64, count)
for i := 0; i < count; i++ {
for i := range count {
ret, hasNext := s.Next()
if !hasNext {
return nil, false
+2 -2
View File
@@ -82,9 +82,9 @@ func TestUniformLazilySample(t *testing.T) {
s.Initialize(3)
for j := 0; j < 2; j++ {
for range 2 {
sampled := map[uint64]bool{}
for i := 0; i < 3; i++ {
for range 3 {
val, hasNext := s.Next()
require.True(hasNext)
require.False(sampled[val])
+1 -1
View File
@@ -57,7 +57,7 @@ func TestWeightedDistribution(t *testing.T) {
require.NoError(s.Initialize([]uint64{1, 1, 2, 3, 4}))
counts := make([]int, 5)
for i := uint64(0); i < 11; i++ {
for i := range uint64(11) {
index, ok := s.Sample(i)
require.True(ok)
counts[index]++
+1 -1
View File
@@ -52,7 +52,7 @@ func (s *weightedUniform) Initialize(weights []uint64) error {
offset := 0
for i, weight := range weights {
for j := uint64(0); j < weight; j++ {
for range weight {
s.indices[offset] = i
offset++
}
@@ -27,7 +27,7 @@ func (s *weightedWithoutReplacementGeneric) Sample(count int) ([]int, bool) {
s.u.Reset()
indices := make([]int, count)
for i := 0; i < count; i++ {
for i := range count {
weight, ok := s.u.Next()
if !ok {
return nil, false