Skip to content

Commit

Permalink
feat: upgrade to go 1.19 (#542)
Browse files Browse the repository at this point in the history
* refactor: remove usage of ioutil

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>

* fix(ci): actually use go 1.19

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 authored Aug 22, 2022
1 parent 0815f5e commit 437d9ef
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 88 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
unit-tests:
strategy:
matrix:
go-version: [ 1.18 ]
go-version: [ 1.19 ]
os: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
Acceptance-Tests:
strategy:
matrix:
go-version: [ 1.18 ]
go-version: [ 1.19 ]
pkgFormat: [ deb, rpm, apk ]
pkgPlatform: [ amd64, arm64, 386, ppc64le, armv6, armv7, s390x ]
runs-on: ubuntu-latest
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
goreleaser:
strategy:
matrix:
go-version: [ 1.18 ]
go-version: [ 1.19 ]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
- run: task docs:build
- uses: wjdp/htmltest-action@master
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
name: setup go
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
-
name: Set up Task
uses: arduino/setup-task@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: ~1.18
go-version: ~1.19
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ By participating to this project, you agree to abide our [code of conduct](https
Prerequisites:

- [Task](https://taskfile.dev/#/installation)
- [Go 1.18+](https://golang.org/doc/install)
- [Go 1.19+](https://golang.org/doc/install)
- [Docker](https://www.docker.com/)
- `gpg` (probably already installed on your system)

Expand Down
5 changes: 2 additions & 3 deletions apk/apk.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
"fmt"
"hash"
"io"
"io/ioutil"
"net/mail"
"os"
"path/filepath"
Expand Down Expand Up @@ -358,7 +357,7 @@ func newScriptInsideTarGz(out *tar.Writer, path, dest string) error {
if err != nil {
return err
}
content, err := ioutil.ReadFile(path)
content, err := os.ReadFile(path)
if err != nil {
return err
}
Expand Down Expand Up @@ -478,7 +477,7 @@ func createSymlinkInsideTarGz(file *files.Content, out *tar.Writer) error {
}

func copyToTarAndDigest(file *files.Content, tw *tar.Writer, sizep *int64) error {
contents, err := ioutil.ReadFile(file.Source)
contents, err := os.ReadFile(file.Source)
if err != nil {
return err
}
Expand Down
30 changes: 15 additions & 15 deletions apk/apk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
"testing"
Expand Down Expand Up @@ -165,7 +165,7 @@ func TestDefaultWithArch(t *testing.T) {
}

func TestNoInfo(t *testing.T) {
err := Default.Package(nfpm.WithDefaults(&nfpm.Info{}), ioutil.Discard)
err := Default.Package(nfpm.WithDefaults(&nfpm.Info{}), io.Discard)
require.Error(t, err)
}

Expand Down Expand Up @@ -200,7 +200,7 @@ func TestFileDoesNotExist(t *testing.T) {
},
},
}),
ioutil.Discard,
io.Discard,
)
require.EqualError(t, err, fmt.Sprintf("matching \"%s\": file does not exist", filepath.ToSlash(abs)))
}
Expand All @@ -223,7 +223,7 @@ func TestNoFiles(t *testing.T) {
},
},
}),
ioutil.Discard,
io.Discard,
)
require.NoError(t, err)
}
Expand All @@ -242,9 +242,9 @@ func TestCreateBuilderControl(t *testing.T) {
control := string(extractFromTar(t, w.Bytes(), ".PKGINFO"))
golden := "testdata/TestCreateBuilderControl.golden"
if *update {
require.NoError(t, ioutil.WriteFile(golden, []byte(control), 0o655)) // nolint: gosec
require.NoError(t, os.WriteFile(golden, []byte(control), 0o655)) // nolint: gosec
}
bts, err := ioutil.ReadFile(golden) //nolint:gosec
bts, err := os.ReadFile(golden) //nolint:gosec
require.NoError(t, err)
require.Equal(t, string(bts), control)
}
Expand Down Expand Up @@ -274,9 +274,9 @@ func TestCreateBuilderControlScripts(t *testing.T) {
control := string(extractFromTar(t, w.Bytes(), ".PKGINFO"))
golden := "testdata/TestCreateBuilderControlScripts.golden"
if *update {
require.NoError(t, ioutil.WriteFile(golden, []byte(control), 0o655)) // nolint: gosec
require.NoError(t, os.WriteFile(golden, []byte(control), 0o655)) // nolint: gosec
}
bts, err := ioutil.ReadFile(golden) //nolint:gosec
bts, err := os.ReadFile(golden) //nolint:gosec
require.NoError(t, err)
require.Equal(t, string(bts), control)

Expand All @@ -303,9 +303,9 @@ func TestControl(t *testing.T) {
}))
golden := "testdata/TestControl.golden"
if *update {
require.NoError(t, ioutil.WriteFile(golden, w.Bytes(), 0o655)) // nolint: gosec
require.NoError(t, os.WriteFile(golden, w.Bytes(), 0o655)) // nolint: gosec
}
bts, err := ioutil.ReadFile(golden) //nolint:gosec
bts, err := os.ReadFile(golden) //nolint:gosec
require.NoError(t, err)
require.Equal(t, string(bts), w.String())
}
Expand All @@ -328,7 +328,7 @@ func TestSignature(t *testing.T) {
err = sign.RSAVerifySHA1Digest(digest, signature, "../internal/sign/testdata/rsa.pub")
require.NoError(t, err)

err = Default.Package(info, ioutil.Discard)
err = Default.Package(info, io.Discard)
require.NoError(t, err)
}

Expand Down Expand Up @@ -377,11 +377,11 @@ func TestDisableGlobbing(t *testing.T) {

gzr, err := gzip.NewReader(&dataTarGz)
require.NoError(t, err)
dataTar, err := ioutil.ReadAll(gzr)
dataTar, err := io.ReadAll(gzr)
require.NoError(t, err)

extractedContent := extractFromTar(t, dataTar, "test/{file}[")
actualContent, err := ioutil.ReadFile("../testdata/{file}[")
actualContent, err := os.ReadFile("../testdata/{file}[")
require.NoError(t, err)
require.Equal(t, actualContent, extractedContent)
}
Expand All @@ -402,7 +402,7 @@ func extractFromTar(t *testing.T, tarFile []byte, fileName string) []byte {
continue
}

data, err := ioutil.ReadAll(tr)
data, err := io.ReadAll(tr)
require.NoError(t, err)
return data
}
Expand Down Expand Up @@ -484,7 +484,7 @@ func TestPackageSymlinks(t *testing.T) {
Type: "symlink",
},
}
require.NoError(t, Default.Package(info, ioutil.Discard))
require.NoError(t, Default.Package(info, io.Discard))
}

func TestDirectories(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions deb/deb.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -664,7 +663,7 @@ func newFilePathInsideTar(out *tar.Writer, path, dest string, mode int64) error
if err != nil {
return err
}
content, err := ioutil.ReadAll(file)
content, err := io.ReadAll(file)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 437d9ef

Please sign in to comment.