Skip to content

Commit

Permalink
Update Go lang and tools version to support new constructs (#223)
Browse files Browse the repository at this point in the history
- Bump golang ver => 1.22.5
  • Loading branch information
arkadiuszos4chain authored Aug 22, 2024
1 parent 8bc5adb commit efa43c6
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 15 deletions.
9 changes: 6 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
module github.com/matryer/moq

go 1.18
go 1.22.5

require (
github.com/pmezard/go-difflib v1.0.0
golang.org/x/tools v0.17.0
golang.org/x/tools v0.24.0
)

require golang.org/x/mod v0.14.0 // indirect
require (
golang.org/x/mod v0.20.0 // indirect
golang.org/x/sync v0.8.0 // indirect
)
11 changes: 6 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc=
golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps=
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -109,5 +108,5 @@ func run(flags userFlags) error {
return err
}

return ioutil.WriteFile(flags.outFile, buf.Bytes(), 0o600)
return os.WriteFile(flags.outFile, buf.Bytes(), 0o600)
}
13 changes: 9 additions & 4 deletions pkg/moq/moq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -407,6 +406,12 @@ func TestMockGolden(t *testing.T) {
interfaces: []string{"ResetStore"},
goldenFile: filepath.Join("testpackages/withresets", "withresets_moq.golden.go"),
},
{
name: "RangeNumber",
cfg: Config{SrcDir: "testpackages/rangenum"},
interfaces: []string{"Magician"},
goldenFile: filepath.Join("testpackages/rangenum", "rangenum_moq.golden.go"),
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
Expand Down Expand Up @@ -464,14 +469,14 @@ func matchGoldenFile(goldenFile string, actual []byte) error {
if err := os.MkdirAll(filepath.Dir(goldenFile), 0o750); err != nil {
return fmt.Errorf("create dir: %s", err)
}
if err := ioutil.WriteFile(goldenFile, actual, 0o600); err != nil {
if err := os.WriteFile(goldenFile, actual, 0o600); err != nil {
return fmt.Errorf("write: %s", err)
}

return nil
}

expected, err := ioutil.ReadFile(goldenFile)
expected, err := os.ReadFile(goldenFile)
if err != nil {
return fmt.Errorf("read: %s: %s", goldenFile, err)
}
Expand Down Expand Up @@ -694,7 +699,7 @@ func TestMockError(t *testing.T) {
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
err := m.Mock(ioutil.Discard, tc.namePair)
err := m.Mock(io.Discard, tc.namePair)
if err == nil {
t.Errorf("expected error but got nil")
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/moq/testpackages/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/matryer/moq/pkg/moq/testpackages

go 1.18
go 1.22.5

require github.com/sudo-suhas/moq-test-pkgs/somerepo v0.0.0-20200816045313-d2f573eea6c7
13 changes: 13 additions & 0 deletions pkg/moq/testpackages/rangenum/rangenum.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package rangenum

import "fmt"

func DoMagic() {

Check failure on line 5 in pkg/moq/testpackages/rangenum/rangenum.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, oldstable)

exported function DoMagic should have comment or be unexported

Check failure on line 5 in pkg/moq/testpackages/rangenum/rangenum.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, stable)

exported function DoMagic should have comment or be unexported

Check failure on line 5 in pkg/moq/testpackages/rangenum/rangenum.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, oldstable)

exported function DoMagic should have comment or be unexported

Check failure on line 5 in pkg/moq/testpackages/rangenum/rangenum.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, stable)

exported function DoMagic should have comment or be unexported
for range 10 {
fmt.Println("abrakadabra")
}
}

type Magician interface {

Check failure on line 11 in pkg/moq/testpackages/rangenum/rangenum.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, oldstable)

exported type Magician should have comment or be unexported

Check failure on line 11 in pkg/moq/testpackages/rangenum/rangenum.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, stable)

exported type Magician should have comment or be unexported

Check failure on line 11 in pkg/moq/testpackages/rangenum/rangenum.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, oldstable)

exported type Magician should have comment or be unexported

Check failure on line 11 in pkg/moq/testpackages/rangenum/rangenum.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, stable)

exported type Magician should have comment or be unexported
DoMagic()
}
67 changes: 67 additions & 0 deletions pkg/moq/testpackages/rangenum/rangenum_moq.golden.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit efa43c6

Please sign in to comment.