Skip to content

Commit 519a84f

Browse files
authored
Merge pull request #486 from abhinavnair/replace-ioutil
Replace deprecated ioutil pkg with os & io
2 parents ca9ddd4 + cc82d49 commit 519a84f

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

cmd/mockery.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ package cmd
33
import (
44
"context"
55
"fmt"
6-
"io/ioutil"
76
"os"
87
"path/filepath"
98
"regexp"
109
"runtime/pprof"
1110
"strings"
1211
"time"
1312

14-
homedir "github.com/mitchellh/go-homedir"
13+
"github.com/mitchellh/go-homedir"
1514
"github.com/pkg/errors"
1615
"github.com/rs/zerolog"
1716
"github.com/rs/zerolog/log"
@@ -99,7 +98,7 @@ func printStackTrace(e error) {
9998
// Execute executes the cobra CLI workflow
10099
func Execute() {
101100
if err := NewRootCmd().Execute(); err != nil {
102-
//printStackTrace(err)
101+
// printStackTrace(err)
103102
os.Exit(1)
104103
}
105104
}
@@ -247,7 +246,7 @@ func (r *RootApp) Run() error {
247246

248247
var boilerplate string
249248
if r.Config.BoilerplateFile != "" {
250-
data, err := ioutil.ReadFile(r.Config.BoilerplateFile)
249+
data, err := os.ReadFile(r.Config.BoilerplateFile)
251250
if err != nil {
252251
log.Fatal().Msgf("Failed to read boilerplate file %s: %v", r.Config.BoilerplateFile, err)
253252
}

pkg/generator_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"context"
66
"go/format"
77
"io"
8-
"io/ioutil"
8+
"os"
99
"path/filepath"
1010
"strings"
1111
"testing"
@@ -1359,15 +1359,15 @@ func NewRequesterReturnElided(t mockConstructorTestingTNewRequesterReturnElided)
13591359
}
13601360

13611361
func (s *GeneratorSuite) TestGeneratorVariadicArgs() {
1362-
expectedBytes, err := ioutil.ReadFile(getMocksPath("RequesterVariadic.go"))
1362+
expectedBytes, err := os.ReadFile(getMocksPath("RequesterVariadic.go"))
13631363
s.NoError(err)
13641364
expected := string(expectedBytes)
13651365
expected = expected[strings.Index(expected, "// RequesterVariadic is"):]
13661366
s.checkGeneration("requester_variadic.go", "RequesterVariadic", false, "", expected)
13671367
}
13681368

13691369
func (s *GeneratorSuite) TestGeneratorVariadicArgsAsOneArg() {
1370-
expectedBytes, err := ioutil.ReadFile(getMocksPath("RequesterVariadicOneArgument.go"))
1370+
expectedBytes, err := os.ReadFile(getMocksPath("RequesterVariadicOneArgument.go"))
13711371
s.NoError(err)
13721372
expected := string(expectedBytes)
13731373
expected = expected[strings.Index(expected, "// RequesterVariadicOneArgument is"):]

pkg/parse.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"go/ast"
77
"go/types"
8-
"io/ioutil"
8+
"os"
99
"path/filepath"
1010
"sort"
1111
"strings"
@@ -73,7 +73,7 @@ func (p *Parser) Parse(ctx context.Context, path string) error {
7373

7474
dir := filepath.Dir(path)
7575

76-
files, err := ioutil.ReadDir(dir)
76+
files, err := os.ReadDir(dir)
7777
if err != nil {
7878
return err
7979
}

pkg/walker.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"fmt"
66
"io"
7-
"io/ioutil"
87
"os"
98
"path/filepath"
109
"regexp"
@@ -70,7 +69,7 @@ func (w *Walker) doWalk(ctx context.Context, p *Parser, dir string, visitor Walk
7069
log := zerolog.Ctx(ctx)
7170
ctx = log.WithContext(ctx)
7271

73-
files, err := ioutil.ReadDir(dir)
72+
files, err := os.ReadDir(dir)
7473
if err != nil {
7574
return
7675
}

0 commit comments

Comments
 (0)