Skip to content

Commit

Permalink
Deprecate ioutil (#17)
Browse files Browse the repository at this point in the history
* deprecate ioutil

* deprecate ioutil from test file
  • Loading branch information
OldPanda authored Aug 10, 2024
1 parent 40984e6 commit e1dd61e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions bloomfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"math"

"github.com/Workiva/go-datastructures/bitarray"
Expand Down Expand Up @@ -80,7 +79,7 @@ func FromBytes(b []byte) (*BloomFilter, error) {
numHashFunctions := int(numHashFuncByte)

// read bitarray capacity
numUint64Bytes, err := ioutil.ReadAll(io.LimitReader(reader, 4))
numUint64Bytes, err := io.ReadAll(io.LimitReader(reader, 4))
if err != nil {
return nil, fmt.Errorf("Failed to read number of bits: %v", err)
}
Expand All @@ -92,7 +91,7 @@ func FromBytes(b []byte) (*BloomFilter, error) {

// put blocks back to bitarray
for blockIdx := 0; blockIdx < int(numUint64); blockIdx++ {
block, err := ioutil.ReadAll(io.LimitReader(reader, 8))
block, err := io.ReadAll(io.LimitReader(reader, 8))
if err != nil {
return nil, fmt.Errorf("Failed to build bitarray: %v", err)
}
Expand Down
8 changes: 4 additions & 4 deletions bloomfilter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package bloomfilter

import (
"bytes"
"io/ioutil"
"io"
"os"
"testing"
)
Expand Down Expand Up @@ -136,7 +136,7 @@ func TestBloomFilterSerialization(t *testing.T) {
func TestJavaCompatibility(t *testing.T) {
file1, _ := os.Open("guava_dump_files/100_0_001_0_to_49_test.dump")
defer file1.Close()
b, _ := ioutil.ReadAll(file1)
b, _ := io.ReadAll(file1)
bf1, err := FromBytes(b)
if err != nil {
t.Errorf("Deserialization from Guava dump file failed: %v", err)
Expand All @@ -154,7 +154,7 @@ func TestJavaCompatibility(t *testing.T) {

file2, _ := os.Open("guava_dump_files/500_0_01_0_to_99_test.dump")
defer file1.Close()
b, _ = ioutil.ReadAll(file2)
b, _ = io.ReadAll(file2)
bf2, err := FromBytes(b)
if err != nil {
t.Errorf("Deserialization from Guava dump file failed: %v", err)
Expand Down Expand Up @@ -223,7 +223,7 @@ func BenchmarkBloomfilterQuery(b *testing.B) {
}
}

var fileContent, _ = ioutil.ReadFile("guava_dump_files/100_0_001_0_to_49_test.dump")
var fileContent, _ = os.ReadFile("guava_dump_files/100_0_001_0_to_49_test.dump")

func BenchmarkBloomfilterDeserialization(b *testing.B) {
for i := 0; i < b.N; i++ {
Expand Down

0 comments on commit e1dd61e

Please sign in to comment.