Skip to content

Commit

Permalink
Don't use "ioutil"
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuniwak committed Mar 12, 2021
1 parent 42a5e01 commit 82bbcef
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 13 deletions.
3 changes: 1 addition & 2 deletions filecollector/repofinder/find_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package repofinder
import (
"github.com/DeNA/unity-meta-check/util/typedpath"
"github.com/google/go-cmp/cmp"
"io/ioutil"
"os"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -88,7 +87,7 @@ func TestFindOnRel(t *testing.T) {
}

func setUpTestDir() typedpath.RawPath {
workDir, err := ioutil.TempDir(os.TempDir(), "unity-meta-check-tests.")
workDir, err := os.MkdirTemp(os.TempDir(), "unity-meta-check-tests.")
if err != nil {
panic(err.Error())
}
Expand Down
3 changes: 1 addition & 2 deletions tool/unity-meta-autofix/autofix/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"github.com/DeNA/unity-meta-check/unity/meta"
"github.com/DeNA/unity-meta-check/util/logging"
"github.com/DeNA/unity-meta-check/util/typedpath"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand All @@ -20,7 +19,7 @@ func TestNewMetaCreator(t *testing.T) {
t.Run(string(metaType), func(t *testing.T) {
spyLogger := logging.SpyLogger()

workDir, err := ioutil.TempDir(os.TempDir(), "")
workDir, err := os.MkdirTemp(os.TempDir(), "")
if err != nil {
panic(err.Error())
}
Expand Down
4 changes: 2 additions & 2 deletions tool/unity-meta-check-github-pr-comment/github/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"fmt"
"github.com/DeNA/unity-meta-check/util/logging"
"io/ioutil"
"io"
"net/http"
"net/url"
"path"
Expand Down Expand Up @@ -47,7 +47,7 @@ func NewPullRequestCommentSender(githubEndpoint *url.URL, token string, send Htt
return err
}

resBody, err := ioutil.ReadAll(res.Body)
resBody, err := io.ReadAll(res.Body)
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions tool/unity-meta-check-github-pr-comment/l10n/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"github.com/DeNA/unity-meta-check/util/typedpath"
"io"
"io/ioutil"
"os"
)

Expand Down Expand Up @@ -59,7 +58,7 @@ func ReadTemplateFile(path typedpath.RawPath) (*Template, error) {
}

func ReadTemplate(reader io.Reader) (*Template, error) {
bytes, err := ioutil.ReadAll(reader)
bytes, err := io.ReadAll(reader)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion tool/unity-meta-check-junit/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestValid(t *testing.T) {
Stderr: stderr,
}

tmpDir, err := ioutil.TempDir(os.TempDir(), "")
tmpDir, err := os.MkdirTemp(os.TempDir(), "")
if err != nil {
t.Errorf("want nil, got %#v", err)
return
Expand Down
4 changes: 2 additions & 2 deletions unity/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package unity
import (
"encoding/json"
"github.com/DeNA/unity-meta-check/util/typedpath"
"io/ioutil"
"os"
)

type ManifestJson struct {
Expand All @@ -13,7 +13,7 @@ type ManifestJson struct {
var ManifestBasename typedpath.BaseName = "manifest.json"

func ReadManifest(path typedpath.RawPath) (*ManifestJson, error) {
bytes, err := ioutil.ReadFile(string(path))
bytes, err := os.ReadFile(string(path))
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions util/cli/prof.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cli
import (
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"runtime/pprof"
Expand Down Expand Up @@ -46,7 +45,7 @@ func NewCommandWithHeapProfile(cmd Command) Command {
}

func newProfFile() (io.WriteCloser, error) {
tmpDir, err := ioutil.TempDir(os.TempDir(), "")
tmpDir, err := os.MkdirTemp(os.TempDir(), "")
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 82bbcef

Please sign in to comment.