From 46b74d3d7986612b6419991b879772d0a4c66577 Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Thu, 10 Aug 2023 13:44:09 -0400 Subject: [PATCH] Bump deps and Go versions (#63) Upgrade release build to use Go 1.20.x. Bump go.mod deps. Add testing on Go 1.21. Remove usage of deprecated io/ioutil. --- .github/workflows/go.yml | 26 ++++++++++----------- .github/workflows/golangci-lint.yml | 6 ++--- .github/workflows/goreleaser.yml | 4 ++-- .golangci.yml | 1 - binrepo.go | 3 +-- cmd/gvm/gvm.go | 4 ++-- go.mod | 14 +++++------ go.sum | 36 +++++++++++++---------------- gvm.go | 3 +-- srcrepo.go | 5 ++-- util.go | 5 ++-- 11 files changed, 49 insertions(+), 58 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 5a9c418..018817d 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -15,13 +15,13 @@ jobs: strategy: matrix: go-version: - - 1.18 - - 1.19 + - '1.20' + - '1.21' steps: - uses: actions/checkout@v3 - name: set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: ${{ matrix.go-version }} @@ -39,13 +39,13 @@ jobs: strategy: matrix: go-version: - - 1.18 - - 1.19 + - '1.20' + - '1.21' steps: - uses: actions/checkout@v3 - name: set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: ${{ matrix.go-version }} @@ -53,29 +53,29 @@ jobs: run: go test ./... test-macos: - name: Go Test (macOS 12) (1.18) + name: Go Test (macOS 12) (1.20) runs-on: macos-12 steps: - uses: actions/checkout@v3 - name: set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: - go-version: 1.18 + go-version: '1.20' - name: go test run: go test ./... test-windows: - name: Go Test (Windows) (1.18) + name: Go Test (Windows) (1.20) runs-on: windows-latest steps: - uses: actions/checkout@v3 - name: set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: - go-version: 1.18 + go-version: '1.20' - name: go test - run: go test ./... \ No newline at end of file + run: go test -timeout 15m ./... \ No newline at end of file diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 62b6f6f..bc5aa2c 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -16,9 +16,9 @@ jobs: name: golangci-lint runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v4 with: - go-version: 1.18 + go-version: '1.20' - uses: actions/checkout@v3 @@ -31,4 +31,4 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.47.0 + version: v1.54.0 diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index 9944fbc..c244164 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -17,9 +17,9 @@ jobs: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: - go-version: '1.18' + go-version: '1.20' - name: Run GoReleaser uses: goreleaser/goreleaser-action@v3 diff --git a/.golangci.yml b/.golangci.yml index 34d7e4e..3e20961 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -18,7 +18,6 @@ linters: - typecheck - unused - varcheck - - depguard - errorlint - gofumpt - goimports diff --git a/binrepo.go b/binrepo.go index c9553e4..a2614dd 100644 --- a/binrepo.go +++ b/binrepo.go @@ -3,7 +3,6 @@ package gvm import ( "encoding/xml" "fmt" - "io/ioutil" "net/http" "net/url" "os" @@ -17,7 +16,7 @@ var reGostoreVersion = regexp.MustCompile(`go(.*)\.(.*)-(.*)\..*`) func (m *Manager) installBinary(version *GoVersion) (string, error) { godir := m.versionDir(version) - tmp, err := ioutil.TempDir("", godir) + tmp, err := os.MkdirTemp("", godir) if err != nil { return "", err } diff --git a/cmd/gvm/gvm.go b/cmd/gvm/gvm.go index 453bb32..e6bd80d 100644 --- a/cmd/gvm/gvm.go +++ b/cmd/gvm/gvm.go @@ -1,7 +1,7 @@ package main import ( - "io/ioutil" + "io" "os" "runtime" "runtime/debug" @@ -95,7 +95,7 @@ func main() { if *debug { logrus.SetOutput(os.Stderr) } else { - logrus.SetOutput(ioutil.Discard) + logrus.SetOutput(io.Discard) } return nil }) diff --git a/go.mod b/go.mod index bc06bcb..5e4ed21 100644 --- a/go.mod +++ b/go.mod @@ -1,20 +1,20 @@ module github.com/andrewkroh/gvm -go 1.17 +go 1.20 require ( github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect - github.com/hashicorp/go-version v1.2.0 - github.com/otiai10/copy v1.2.0 - github.com/sirupsen/logrus v1.4.2 - github.com/stretchr/testify v1.3.0 + github.com/hashicorp/go-version v1.6.0 + github.com/otiai10/copy v1.12.0 + github.com/sirupsen/logrus v1.9.3 + github.com/stretchr/testify v1.7.0 gopkg.in/alecthomas/kingpin.v2 v2.2.6 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86 // indirect + golang.org/x/sys v0.11.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect ) diff --git a/go.sum b/go.sum index b035d22..bd7ef0f 100644 --- a/go.sum +++ b/go.sum @@ -5,28 +5,24 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/otiai10/copy v1.2.0 h1:HvG945u96iNadPoG2/Ja2+AUJeW5YuFQMixq9yirC+k= -github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= -github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= -github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= -github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= -github.com/otiai10/mint v1.3.1 h1:BCmzIS3n71sGfHB5NMNDB3lHYPz8fWSkCAErHed//qc= -github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= +github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= +github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/otiai10/copy v1.12.0 h1:cLMgSQnXBs1eehF0Wy/FAGsgDTDmAqFR7rQylBb1nDY= +github.com/otiai10/copy v1.12.0/go.mod h1:rSaLseMUsZFFbsFGc7wCJnnkTAvdc5L6VWxPE4308Ww= +github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86 h1:A9i04dxx7Cribqbs8jf3FQLogkL/CV2YN7hj9KWJCkc= -golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/gvm.go b/gvm.go index e47336c..8bec394 100644 --- a/gvm.go +++ b/gvm.go @@ -3,7 +3,6 @@ package gvm import ( "errors" "fmt" - "io/ioutil" "os" "path/filepath" "runtime" @@ -192,7 +191,7 @@ func (m *Manager) Remove(version *GoVersion) error { // Installed returns all installed go version func (m *Manager) Installed() ([]*GoVersion, error) { - files, err := ioutil.ReadDir(m.versionsDir) + files, err := os.ReadDir(m.versionsDir) if err != nil { return nil, err } diff --git a/srcrepo.go b/srcrepo.go index 599e2fb..6933927 100644 --- a/srcrepo.go +++ b/srcrepo.go @@ -3,7 +3,6 @@ package gvm import ( "errors" "fmt" - "io/ioutil" "log" "os" "path/filepath" @@ -90,7 +89,7 @@ func (m *Manager) installSrc(version *GoVersion) (string, error) { godir := m.versionDir(version) log.Println("create temp directory") - tmpRoot, err := ioutil.TempDir("", godir) + tmpRoot, err := os.MkdirTemp("", godir) if err != nil { return "", err } @@ -138,7 +137,7 @@ func buildGo(log logrus.FieldLogger, buildDir, repo string, version *GoVersion, if !version.IsTip() { // write VERSION file versionFile := filepath.Join(tmp, "VERSION") - err := ioutil.WriteFile(versionFile, []byte(version.String()), 0o644) + err := os.WriteFile(versionFile, []byte(version.String()), 0o644) if err != nil { return err } diff --git a/util.go b/util.go index d299796..8f33fdf 100644 --- a/util.go +++ b/util.go @@ -3,7 +3,6 @@ package gvm import ( "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "runtime" @@ -61,11 +60,11 @@ func writeJSONFile(filename string, value interface{}) error { if err != nil { return err } - return ioutil.WriteFile(filename, contents, 0o644) + return os.WriteFile(filename, contents, 0o644) } func readJSONFile(filename string, to interface{}) error { - contents, err := ioutil.ReadFile(filename) + contents, err := os.ReadFile(filename) if err != nil { return err }