diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml index 9d359da..fa1ae7c 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/go.yaml @@ -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: @@ -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 diff --git a/README.md b/README.md index a781d59..e12b583 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ For applying suggested fix, use `-apply` flag, instead of `-fix`. ## Development -Go 1.18+ +Go 1.20+ ### Running test diff --git a/go.mod b/go.mod index abb4a54..aa798d4 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index 975ce2e..0686992 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/structslop.go b/structslop.go index 7a2d762..df1d571 100644 --- a/structslop.go +++ b/structslop.go @@ -23,7 +23,6 @@ import ( "go/parser" "go/token" "go/types" - "io/ioutil" "os" "sort" "strings" @@ -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) } } diff --git a/structslop_test.go b/structslop_test.go index 699c902..4a2eb1b 100644 --- a/structslop_test.go +++ b/structslop_test.go @@ -16,7 +16,6 @@ package structslop_test import ( "bytes" - "io/ioutil" "os" "path/filepath" "strings" @@ -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() @@ -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)) }