Skip to content

Commit

Permalink
"io/ioutil" has been deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
sue445 committed Jul 13, 2024
1 parent b6fd56a commit af21686
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
3 changes: 1 addition & 2 deletions lib/erd_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"github.com/cockroachdb/errors"
"github.com/sue445/plant_erd/db"
"io/ioutil"
"os"
"regexp"
)
Expand Down Expand Up @@ -97,7 +96,7 @@ func (g *ErdGenerator) output(content string) error {
}

// Output to file
err := ioutil.WriteFile(g.Filepath, []byte(content), 0644)
err := os.WriteFile(g.Filepath, []byte(content), 0644)
if err != nil {
return errors.WithStack(err)
}
Expand Down
11 changes: 2 additions & 9 deletions lib/erd_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package lib
import (
"bytes"
"io"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -208,13 +207,7 @@ func TestErdGenerator_generateMermaidErd(t *testing.T) {
}

func TestErdGenerator_output_ToFile(t *testing.T) {
dir, err := ioutil.TempDir("", "example")

if err != nil {
panic(err)
}

defer os.RemoveAll(dir)
dir := t.TempDir()

filePath := filepath.Join(dir, "erd.txt")
g := &ErdGenerator{
Expand All @@ -223,7 +216,7 @@ func TestErdGenerator_output_ToFile(t *testing.T) {

g.output("aaa")

Check failure on line 217 in lib/erd_generator_test.go

View workflow job for this annotation

GitHub Actions / Lint

Error return value of `g.output` is not checked (errcheck)

data, err := ioutil.ReadFile(filePath)
data, err := os.ReadFile(filePath)

if assert.NoError(t, err) {
str := string(data)
Expand Down

0 comments on commit af21686

Please sign in to comment.