Skip to content

Commit 3beda07

Browse files
committed
fix: remove usage of io/ioutil
Signed-off-by: ismael FALL <[email protected]>
1 parent ca6b73e commit 3beda07

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

internal/dvcore/run_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ package dvcore
22

33
import (
44
"bytes"
5-
"io/ioutil"
65
"os"
76
"testing"
87

9-
"github.com/cayleygraph/cayley/graph"
10-
"github.com/cayleygraph/quad"
11-
"github.com/stretchr/testify/assert"
128
"moul.io/depviz/v3/internal/dvstore"
139
"moul.io/depviz/v3/internal/testutil"
1410
"moul.io/multipmuri"
11+
12+
"github.com/cayleygraph/cayley/graph"
13+
"github.com/cayleygraph/quad"
14+
"github.com/stretchr/testify/assert"
1515
)
1616

1717
func TestPullAndSave(t *testing.T) {
@@ -82,11 +82,11 @@ func TestPullAndSave(t *testing.T) {
8282
gp := dvstore.TestingGoldenDumpPath(t, test.name)
8383
if testutil.UpdateGolden() {
8484
t.Logf("update golden file: %s", gp)
85-
err := ioutil.WriteFile(gp, b.Bytes(), 0644)
85+
err := os.WriteFile(gp, b.Bytes(), 0644)
8686
assert.NoError(t, err, test.name)
8787
}
8888

89-
g, err := ioutil.ReadFile(gp)
89+
g, err := os.ReadFile(gp)
9090
assert.NoError(t, err, test.name)
9191
assert.Equal(t, string(g), b.String())
9292
}

internal/dvserver/api.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"context"
66
"encoding/base64"
77
"fmt"
8-
"io/ioutil"
8+
"io"
99
"net/http"
1010

1111
"go.uber.org/zap"
@@ -24,7 +24,7 @@ func gitHubOAuth(opts Opts, httpLogger *zap.Logger) http.HandlerFunc {
2424
return
2525
}
2626

27-
code, err := ioutil.ReadAll(r.Body)
27+
code, err := io.ReadAll(r.Body)
2828
if err != nil {
2929
httpLogger.Error("get body", zap.Error(err))
3030
http.Error(w, "failed to retrieve body", http.StatusInternalServerError)
@@ -63,7 +63,7 @@ func gitHubOAuth(opts Opts, httpLogger *zap.Logger) http.HandlerFunc {
6363

6464
defer gitHubResponse.Body.Close()
6565

66-
token, err := ioutil.ReadAll(gitHubResponse.Body)
66+
token, err := io.ReadAll(gitHubResponse.Body)
6767
if err != nil {
6868
httpLogger.Error("get body", zap.Error(err))
6969
http.Error(w, "internal server error", http.StatusInternalServerError)

internal/dvstore/query.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import (
66
"sort"
77
"time"
88

9+
"go.uber.org/zap"
10+
"moul.io/depviz/v3/internal/dvmodel"
11+
"moul.io/multipmuri"
12+
913
"github.com/cayleygraph/cayley"
1014
"github.com/cayleygraph/cayley/graph/path"
1115
"github.com/cayleygraph/cayley/schema"
1216
"github.com/cayleygraph/quad"
13-
"go.uber.org/zap"
14-
"moul.io/depviz/v3/internal/dvmodel"
15-
"moul.io/multipmuri"
1617
)
1718

1819
func LastUpdatedIssueInRepo(ctx context.Context, h *cayley.Handle, entity multipmuri.Entity) (time.Time, error) { // nolint:interfacer

internal/dvstore/query_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ package dvstore
22

33
import (
44
"fmt"
5-
"io/ioutil"
5+
"os"
66
"strings"
77
"testing"
88

9-
_ "github.com/cayleygraph/quad/json"
10-
"github.com/stretchr/testify/assert"
119
"moul.io/depviz/v3/internal/dvparser"
1210
"moul.io/depviz/v3/internal/testutil"
1311
"moul.io/godev"
1412
"moul.io/multipmuri"
13+
14+
_ "github.com/cayleygraph/quad/json"
15+
"github.com/stretchr/testify/assert"
1516
)
1617

1718
func TestLoadTasks(t *testing.T) {
@@ -62,7 +63,7 @@ func TestLoadTasks(t *testing.T) {
6263

6364
if testutil.UpdateGolden() {
6465
t.Logf("update golden file: %s", gp)
65-
err := ioutil.WriteFile(gp, []byte(actual), 0644)
66+
err := os.WriteFile(gp, []byte(actual), 0644)
6667
assert.NoError(t, err, name)
6768
}
6869

@@ -82,7 +83,7 @@ func TestLoadTasks(t *testing.T) {
8283
}
8384
}
8485

85-
g, err := ioutil.ReadFile(gp)
86+
g, err := os.ReadFile(gp)
8687
assert.NoError(t, err, name)
8788
assert.Equal(t, len(string(g)), len(actual), gp)
8889
})

internal/dvstore/testing.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package dvstore
22

33
import (
4-
"io/ioutil"
54
"os"
65
"path/filepath"
76
"strings"
@@ -78,7 +77,7 @@ func TestingGoldenStore(t *testing.T, name string) (*cayley.Handle, func()) {
7877
func TestingStore(t *testing.T) (*cayley.Handle, func()) {
7978
t.Helper()
8079

81-
dir, err := ioutil.TempDir("", "depviz")
80+
dir, err := os.MkdirTemp("", "depviz")
8281
require.NoError(t, err)
8382

8483
err = graph.InitQuadStore("bolt", dir, nil)

0 commit comments

Comments
 (0)