Skip to content

Commit efa43c6

Browse files
Update Go lang and tools version to support new constructs (#223)
- Bump golang ver => 1.22.5
1 parent 8bc5adb commit efa43c6

File tree

7 files changed

+103
-15
lines changed

7 files changed

+103
-15
lines changed

go.mod

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
module github.com/matryer/moq
22

3-
go 1.18
3+
go 1.22.5
44

55
require (
66
github.com/pmezard/go-difflib v1.0.0
7-
golang.org/x/tools v0.17.0
7+
golang.org/x/tools v0.24.0
88
)
99

10-
require golang.org/x/mod v0.14.0 // indirect
10+
require (
11+
golang.org/x/mod v0.20.0 // indirect
12+
golang.org/x/sync v0.8.0 // indirect
13+
)

go.sum

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
22
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3-
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
4-
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
5-
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
6-
golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc=
7-
golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps=
3+
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
4+
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
5+
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
6+
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
7+
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
8+
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=

main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"flag"
77
"fmt"
88
"io"
9-
"io/ioutil"
109
"os"
1110
"path/filepath"
1211

@@ -109,5 +108,5 @@ func run(flags userFlags) error {
109108
return err
110109
}
111110

112-
return ioutil.WriteFile(flags.outFile, buf.Bytes(), 0o600)
111+
return os.WriteFile(flags.outFile, buf.Bytes(), 0o600)
113112
}

pkg/moq/moq_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"flag"
66
"fmt"
77
"io"
8-
"io/ioutil"
98
"os"
109
"os/exec"
1110
"path/filepath"
@@ -407,6 +406,12 @@ func TestMockGolden(t *testing.T) {
407406
interfaces: []string{"ResetStore"},
408407
goldenFile: filepath.Join("testpackages/withresets", "withresets_moq.golden.go"),
409408
},
409+
{
410+
name: "RangeNumber",
411+
cfg: Config{SrcDir: "testpackages/rangenum"},
412+
interfaces: []string{"Magician"},
413+
goldenFile: filepath.Join("testpackages/rangenum", "rangenum_moq.golden.go"),
414+
},
410415
}
411416
for _, tc := range cases {
412417
t.Run(tc.name, func(t *testing.T) {
@@ -464,14 +469,14 @@ func matchGoldenFile(goldenFile string, actual []byte) error {
464469
if err := os.MkdirAll(filepath.Dir(goldenFile), 0o750); err != nil {
465470
return fmt.Errorf("create dir: %s", err)
466471
}
467-
if err := ioutil.WriteFile(goldenFile, actual, 0o600); err != nil {
472+
if err := os.WriteFile(goldenFile, actual, 0o600); err != nil {
468473
return fmt.Errorf("write: %s", err)
469474
}
470475

471476
return nil
472477
}
473478

474-
expected, err := ioutil.ReadFile(goldenFile)
479+
expected, err := os.ReadFile(goldenFile)
475480
if err != nil {
476481
return fmt.Errorf("read: %s: %s", goldenFile, err)
477482
}
@@ -694,7 +699,7 @@ func TestMockError(t *testing.T) {
694699
}
695700
for _, tc := range cases {
696701
t.Run(tc.name, func(t *testing.T) {
697-
err := m.Mock(ioutil.Discard, tc.namePair)
702+
err := m.Mock(io.Discard, tc.namePair)
698703
if err == nil {
699704
t.Errorf("expected error but got nil")
700705
return

pkg/moq/testpackages/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module github.com/matryer/moq/pkg/moq/testpackages
22

3-
go 1.18
3+
go 1.22.5
44

55
require github.com/sudo-suhas/moq-test-pkgs/somerepo v0.0.0-20200816045313-d2f573eea6c7
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package rangenum
2+
3+
import "fmt"
4+
5+
func DoMagic() {
6+
for range 10 {
7+
fmt.Println("abrakadabra")
8+
}
9+
}
10+
11+
type Magician interface {
12+
DoMagic()
13+
}

pkg/moq/testpackages/rangenum/rangenum_moq.golden.go

Lines changed: 67 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)