Skip to content

Commit

Permalink
fix: replace deprecated function ioutil.ReadFile
Browse files Browse the repository at this point in the history
  • Loading branch information
wI2L committed Apr 29, 2023
1 parent 1f8c0bb commit d01e0ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ package jsondiff

import (
"encoding/json"
"io/ioutil"
"os"
"testing"
)

func BenchmarkMedium(b *testing.B) {
beforeBytes, err := ioutil.ReadFile("testdata/benchs/medium/before.json")
beforeBytes, err := os.ReadFile("testdata/benchs/medium/before.json")
if err != nil {
b.Fatal(err)
}
afterBytesOrdered, err := ioutil.ReadFile("testdata/benchs/medium/after-ordered.json")
afterBytesOrdered, err := os.ReadFile("testdata/benchs/medium/after-ordered.json")
if err != nil {
b.Fatal(err)
}
afterBytesUnordered, err := ioutil.ReadFile("testdata/benchs/medium/after-unordered.json")
afterBytesUnordered, err := os.ReadFile("testdata/benchs/medium/after-unordered.json")
if err != nil {
b.Fatal(err)
}
Expand Down Expand Up @@ -47,6 +47,9 @@ func BenchmarkMedium(b *testing.B) {
b.Fatal(err)
}
b.Run("Compare/"+bb.name, func(b *testing.B) {
if testing.Short() {
b.Skip()
}
for i := 0; i < b.N; i++ {
patch, err := CompareOpts(before, after, bb.opts...)
if err != nil {
Expand All @@ -56,6 +59,9 @@ func BenchmarkMedium(b *testing.B) {
}
})
b.Run("CompareJSON/"+bb.name, func(b *testing.B) {
if testing.Short() {
b.Skip()
}
for i := 0; i < b.N; i++ {
patch, err := CompareJSONOpts(beforeBytes, bb.afterBytes, bb.opts...)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package jsondiff
import (
"encoding/json"
"hash/maphash"
"io/ioutil"
"os"
"testing"
)

func readJSON(filename string) (interface{}, error) {
b, err := ioutil.ReadFile(filename)
b, err := os.ReadFile(filename)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit d01e0ea

Please sign in to comment.