Skip to content

Commit 80986ef

Browse files
authored
Merge pull request #502 from happygiraffe/master
small cleanups
2 parents 45a287e + af00e64 commit 80986ef

File tree

13 files changed

+36
-44
lines changed

13 files changed

+36
-44
lines changed

.github/workflows/armtests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
test:
88
strategy:
99
matrix:
10-
go-version: [1.22.x]
10+
go-version: [1.24.x]
1111
platform: [ubuntu-latest]
1212
runs-on: ${{ matrix.platform }}
1313
steps:

.github/workflows/basictests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
test:
88
strategy:
99
matrix:
10-
go-version: [1.22.x]
10+
go-version: [1.24.x]
1111
platform: [ubuntu-latest]
1212
runs-on: ${{ matrix.platform }}
1313
steps:

.github/workflows/bigendiantests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
test:
88
strategy:
99
matrix:
10-
go-version: [1.22.x]
10+
go-version: [1.24.x]
1111
platform: [ubuntu-latest]
1212
runs-on: ${{ matrix.platform }}
1313
steps:

.github/workflows/legacytests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
test:
88
strategy:
99
matrix:
10-
go-version: [1.22.x]
10+
go-version: [1.24.x]
1111
platform: [ubuntu-latest]
1212
runs-on: ${{ matrix.platform }}
1313
steps:

.github/workflows/macostests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
test:
88
strategy:
99
matrix:
10-
go-version: [1.22.x]
10+
go-version: [1.24.x]
1111
platform: [macos-latest]
1212
runs-on: ${{ matrix.platform }}
1313
steps:

.github/workflows/windowstests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
test:
88
strategy:
99
matrix:
10-
go-version: [1.22.x]
10+
go-version: [1.24.x]
1111
platform: [windows-latest]
1212
runs-on: ${{ matrix.platform }}
1313
steps:

iter.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package roaring
22

3+
import "iter"
4+
35
// Values returns an iterator that yields the elements of the bitmap in
46
// increasing order. Starting with Go 1.23, users can use a for loop to iterate
57
// over it.
6-
func Values(b *Bitmap) func(func(uint32) bool) {
8+
func Values(b *Bitmap) iter.Seq[uint32] {
79
return func(yield func(uint32) bool) {
810
it := b.Iterator()
911
for it.HasNext() {
@@ -17,7 +19,7 @@ func Values(b *Bitmap) func(func(uint32) bool) {
1719
// Backward returns an iterator that yields the elements of the bitmap in
1820
// decreasing order. Starting with Go 1.23, users can use a for loop to iterate
1921
// over it.
20-
func Backward(b *Bitmap) func(func(uint32) bool) {
22+
func Backward(b *Bitmap) iter.Seq[uint32] {
2123
return func(yield func(uint32) bool) {
2224
it := b.ReverseIterator()
2325
for it.HasNext() {
@@ -30,7 +32,7 @@ func Backward(b *Bitmap) func(func(uint32) bool) {
3032

3133
// Unset creates an iterator that yields values in the range [min, max] that are NOT contained in the bitmap.
3234
// The iterator becomes invalid if the bitmap is modified (e.g., with Add or Remove).
33-
func Unset(b *Bitmap, min, max uint32) func(func(uint32) bool) {
35+
func Unset(b *Bitmap, min, max uint32) iter.Seq[uint32] {
3436
return func(yield func(uint32) bool) {
3537
it := b.UnsetIterator(uint64(min), uint64(max)+1)
3638
for it.HasNext() {

roaring64/bsi64_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"encoding/binary"
66
"fmt"
77
"io"
8-
"io/ioutil"
98
"math/big"
109
"math/rand"
1110
"os"
@@ -645,11 +644,10 @@ func TestMinMaxWithNilFoundSet(t *testing.T) {
645644
}
646645

647646
func TestBSIWriteToReadFrom(t *testing.T) {
648-
file, err := ioutil.TempFile("./testdata", "bsi-test")
647+
file, err := os.CreateTemp(t.TempDir(), "bsi-test")
649648
if err != nil {
650649
t.Fatal(err)
651650
}
652-
defer t.Cleanup(func() { os.Remove(file.Name()) })
653651
defer file.Close()
654652
bsi, min, max := setupRandom()
655653
_, err = bsi.WriteTo(file)

roaring64/iter.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package roaring64
22

3+
import "iter"
4+
35
// Values returns an iterator that yields the elements of the bitmap in
46
// increasing order. Starting with Go 1.23, users can use a for loop to iterate
57
// over it.
6-
func Values(b *Bitmap) func(func(uint64) bool) {
8+
func Values(b *Bitmap) iter.Seq[uint64] {
79
return func(yield func(uint64) bool) {
810
it := b.Iterator()
911
for it.HasNext() {
@@ -17,7 +19,7 @@ func Values(b *Bitmap) func(func(uint64) bool) {
1719
// Backward returns an iterator that yields the elements of the bitmap in
1820
// decreasing order. Starting with Go 1.23, users can use a for loop to iterate
1921
// over it.
20-
func Backward(b *Bitmap) func(func(uint64) bool) {
22+
func Backward(b *Bitmap) iter.Seq[uint64] {
2123
return func(yield func(uint64) bool) {
2224
it := b.ReverseIterator()
2325
for it.HasNext() {

roaring64/serialization_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"bytes"
77
"fmt"
88
"io"
9-
"io/ioutil"
109
"math"
1110
"os"
1211
"path/filepath"
@@ -87,7 +86,7 @@ func TestSerializationBasic037(t *testing.T) {
8786

8887
func TestSerializationToFile038(t *testing.T) {
8988
rb := BitmapOf(1, 2, 3, 4, 5, 100, 1000)
90-
fname := "myfile.bin"
89+
fname := filepath.Join(t.TempDir(), "myfile.bin")
9190
fout, err := os.OpenFile(fname, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o660)
9291
if err != nil {
9392
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
@@ -114,10 +113,7 @@ func TestSerializationToFile038(t *testing.T) {
114113
buf := bytes.NewBuffer(nil)
115114
teer := io.TeeReader(fin, buf)
116115

117-
defer func() {
118-
fin.Close()
119-
_ = os.Remove(fname)
120-
}()
116+
defer fin.Close()
121117

122118
_, _ = newrb.ReadFrom(teer)
123119
assert.True(t, rb.Equals(newrb))
@@ -276,7 +272,7 @@ func Test_tryReadFromRoaring32WithRoaring64(t *testing.T) {
276272
}
277273

278274
func Test_tryReadFromRoaring32WithRoaring64_File(t *testing.T) {
279-
tempDir, err := ioutil.TempDir("./", "testdata")
275+
tempDir, err := os.MkdirTemp("./", "testdata")
280276
if err != nil {
281277
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
282278
return
@@ -290,7 +286,7 @@ func Test_tryReadFromRoaring32WithRoaring64_File(t *testing.T) {
290286
}
291287

292288
name := filepath.Join(tempDir, "r32")
293-
if err := ioutil.WriteFile(name, bs, 0o600); err != nil {
289+
if err := os.WriteFile(name, bs, 0o600); err != nil {
294290
t.Fatal(err)
295291
}
296292
file, err := os.Open(name)

0 commit comments

Comments
 (0)