Skip to content

Commit

Permalink
Switch from golang 1.17 to 1.20 (#24)
Browse files Browse the repository at this point in the history
Currently targeting golang 1.20.2.

With the golang upgrade we also fixed the following:

- fixed deprecated API usage (mostly `ioutil` to `os`)
- bumped golangci-lint to 1.52.0
  • Loading branch information
zmoog authored Mar 20, 2023
1 parent 2efdd84 commit 182a1b1
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.17.9'
go-version: '1.20.2'
- name: golangci-lint
uses: golangci/[email protected]
with:
Expand All @@ -30,7 +30,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.17.9'
go-version: '1.20.2'
- run: make test
build:
name: Build binaries
Expand All @@ -45,5 +45,5 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.17.9'
go-version: '1.20.2'
- run: make build
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.20.2
- name: Install gon for code signing and notarization
run: |
wget -q https://github.com/mitchellh/gon/releases/download/v0.2.5/gon_macos.zip -O /tmp/gon_macos.zip
Expand Down
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
golang 1.17.9
golangci-lint 1.42.1
golang 1.20.2
golangci-lint 1.52.0
mockery 2.12.0
5 changes: 2 additions & 3 deletions adapters/spaggiari/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -102,7 +101,7 @@ func (ls FilesystemLoaderStorer) Load() (Identity, bool, error) {
return noIdentity, false, nil
}

data, err := ioutil.ReadFile(configFilePath)
data, err := os.ReadFile(configFilePath)
if err != nil {
return noIdentity, false, err
}
Expand All @@ -128,7 +127,7 @@ func (ls FilesystemLoaderStorer) Store(identity Identity) error {
return err
}

err = ioutil.WriteFile(filepath.Join(path, "identity.json"), data, 0700)
err = os.WriteFile(filepath.Join(path, "identity.json"), data, 0700)
if err != nil {
return err
}
Expand Down
9 changes: 5 additions & 4 deletions adapters/spaggiari/identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package spaggiari_test

import (
"bytes"
"io/ioutil"
"io"
"net/http"
"os"
"testing"
"time"

Expand Down Expand Up @@ -52,7 +53,7 @@ func TestInMemoryLoaderStorer(t *testing.T) {

func TestFilesystemLoaderStorer(t *testing.T) {
t.Run("Load from empty an store", func(t *testing.T) {
path, err := ioutil.TempDir("", "")
path, err := os.MkdirTemp("", "")
if err != nil {
t.Error(err)
}
Expand All @@ -72,7 +73,7 @@ func TestFilesystemLoaderStorer(t *testing.T) {
})

t.Run("Store and load the identity", func(t *testing.T) {
path, err := ioutil.TempDir("", "")
path, err := os.MkdirTemp("", "")
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -220,7 +221,7 @@ Reference #18.a6b93554.1651609703.877e15
</HTML>`

// create a new reader with that JSON
r := ioutil.NopCloser(bytes.NewReader([]byte(response)))
r := io.NopCloser(bytes.NewReader([]byte(response)))

fetcher := spaggiari.IdentityFetcher{
Client: &mocks.MockClient{
Expand Down
4 changes: 2 additions & 2 deletions commands/agenda_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package commands_test

import (
"bytes"
"io/ioutil"
"os"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -63,7 +63,7 @@ func TestListAgendaCommand(t *testing.T) {
err := cmd.ExecuteWith(uow)
assert.Nil(t, err)

expected, err := ioutil.ReadFile("testdata/agenda.out.txt")
expected, err := os.ReadFile("testdata/agenda.out.txt")
if err != nil {
t.Errorf("can't read test data from %v: %v", "testdata/agenda.out.txt", err)
}
Expand Down
3 changes: 1 addition & 2 deletions commands/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package commands_test
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
)

Expand All @@ -19,7 +18,7 @@ func UnmarshalFrom(path string, v interface{}) error {
return fmt.Errorf("can't read from %v", path)
}

content, err := ioutil.ReadFile(path)
content, err := os.ReadFile(path)
if err != nil {
return fmt.Errorf("can't read test data from %v: %w", path, err)
}
Expand Down
4 changes: 2 additions & 2 deletions commands/grades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package commands_test

import (
"bytes"
"io/ioutil"
"os"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -56,7 +56,7 @@ func TestListGradesCommand(t *testing.T) {
err := cmd.ExecuteWith(uow)
assert.Nil(t, err)

expected, err := ioutil.ReadFile("testdata/grades.out.txt")
expected, err := os.ReadFile("testdata/grades.out.txt")
if err != nil {
t.Errorf("can't read test data from %v: %v", "testdata/grades.out.txt", err)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/zmoog/classeviva

go 1.17
go 1.20

require (
github.com/jedib0t/go-pretty/v6 v6.3.1
Expand Down

0 comments on commit 182a1b1

Please sign in to comment.