Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.18.x
go-version: 1.20.x
- name: Cache
uses: actions/cache@v2
with:
Expand All @@ -35,7 +35,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.18.x
go-version: 1.20.x
- run: go install golang.org/dl/gotip@latest
- run: gotip download
- run: gotip version
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ For applying suggested fix, use `-apply` flag, instead of `-fix`.

## Development

Go 1.18+
Go 1.20+

### Running test

Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/orijtech/structslop

go 1.18
go 1.20

require (
github.com/dave/dst v0.27.0
golang.org/x/tools v0.1.11
github.com/dave/dst v0.27.2
golang.org/x/tools v0.8.0
)

require (
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/sys v0.7.0 // indirect
)
17 changes: 9 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
github.com/dave/dst v0.27.0 h1:vh51Zc/7bH5YfbspFsEizLuQ1xm6zDQWMJiIlZhiNQ4=
github.com/dave/dst v0.27.0/go.mod h1:eF/UOVnw9Ech3NkZFCdtujtISJFRYf11+I93p+RI5S4=
github.com/dave/dst v0.27.2 h1:4Y5VFTkhGLC1oddtNwuxxe36pnyLxMFXT51FOzH8Ekc=
github.com/dave/dst v0.27.2/go.mod h1:jHh6EOibnHgcUW3WjKHisiooEkYwqpHLBSX1iOBhEyc=
github.com/dave/jennifer v1.5.0 h1:HmgPN93bVDpkQyYbqhCHj5QlgvUkvEOzMyEvKLgCRrg=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e h1:CsOuNlbOuf0mzxJIefr6Q4uAUetRUwZE4qt7VfzP+xo=
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.1.11 h1:loJ25fNOEhSXfHrpoGj91eCUThwdNX6u24rO1xnNteY=
golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4=
golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y=
golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4=
3 changes: 1 addition & 2 deletions structslop.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"go/parser"
"go/token"
"go/types"
"io/ioutil"
"os"
"sort"
"strings"
Expand Down Expand Up @@ -187,7 +186,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
if err := fi.Close(); err != nil {
_, _ = fmt.Fprintf(os.Stderr, "failed to close file: %v", err)
}
if err := ioutil.WriteFile(fn, content, st.Mode()); err != nil {
if err := os.WriteFile(fn, content, st.Mode()); err != nil {
_, _ = fmt.Fprintf(os.Stderr, "failed to write suggested fix to file: %v", err)
}
}
Expand Down
11 changes: 5 additions & 6 deletions structslop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package structslop_test

import (
"bytes"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand All @@ -34,14 +33,14 @@ func Test(t *testing.T) {

func TestApply(t *testing.T) {
dir := strings.Join([]string{".", "testdata", "src"}, string(os.PathSeparator))
tmpdir, err := ioutil.TempDir(dir, "structslop-test-apply-")
tmpdir, err := os.MkdirTemp(dir, "structslop-test-apply-")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tmpdir)
fn := filepath.Join(tmpdir, "p.go")
src, _ := ioutil.ReadFile(filepath.Join(".", "testdata", "src", "struct", "p.go"))
if err := ioutil.WriteFile(fn, src, 0644); err != nil {
src, _ := os.ReadFile(filepath.Join(".", "testdata", "src", "struct", "p.go"))
if err := os.WriteFile(fn, src, 0644); err != nil {
t.Fatal(err)
}
testdata := analysistest.TestData()
Expand All @@ -50,8 +49,8 @@ func TestApply(t *testing.T) {
_ = structslop.Analyzer.Flags.Set("apply", "false")
}()
analysistest.Run(t, testdata, structslop.Analyzer, filepath.Base(tmpdir))
got, _ := ioutil.ReadFile(fn)
expected, _ := ioutil.ReadFile(filepath.Join(".", "testdata", "src", "struct", "p.go.golden"))
got, _ := os.ReadFile(fn)
expected, _ := os.ReadFile(filepath.Join(".", "testdata", "src", "struct", "p.go.golden"))
if !bytes.Equal(expected, got) {
t.Errorf("unexpected suggested fix, want:\n%s\ngot:\n%s\n", string(expected), string(got))
}
Expand Down