Skip to content

Commit

Permalink
feat: use Go 1.21 and adapt code
Browse files Browse the repository at this point in the history
  • Loading branch information
bfabio committed Feb 20, 2024
1 parent 3688938 commit cd2cc02
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.18'
go-version: '1.21'
- uses: golangci/golangci-lint-action@v3
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ^1.18
go-version: ^1.21
id: go
-
name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_and_publish_docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: '1.18'
go-version: '1.21'
- run: go build
- run: go test -race ./...

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.18 as build
FROM golang:1.21 as build

WORKDIR /src
COPY . .
Expand Down
6 changes: 3 additions & 3 deletions cmd/download_publishers.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
"io/ioutil"
"io"
"log"
"net/http"
"net/url"
Expand Down Expand Up @@ -33,7 +33,7 @@ var downloadPublishersCmd = &cobra.Command{
Run: func(_ *cobra.Command, args []string) {
var publishers []common.Publisher
if _, err := os.Stat(args[1]); err == nil {
data, err := ioutil.ReadFile(args[1])
data, err := os.ReadFile(args[1])
if err != nil {
log.Fatalf("error in reading %s: %v", args[1], err)
}
Expand All @@ -45,7 +45,7 @@ var downloadPublishersCmd = &cobra.Command{
log.Fatal(err)
}
defer resp.Body.Close()
bodyBytes, err := ioutil.ReadAll(resp.Body)
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions common/lists_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package common

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

"github.com/stretchr/testify/assert"
Expand All @@ -16,7 +16,7 @@ type FakeReadFiler struct {

func (f FakeReadFiler) ReadFile(filename string) ([]byte, error) {
buf := bytes.NewBufferString(f.Str)
return ioutil.ReadAll(buf)
return io.ReadAll(buf)
}

func TestReadPublishers(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions common/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package common

import (
"fmt"
"io/ioutil"
"os"

url "github.com/italia/publiccode-crawler/v4/internal"
"gopkg.in/yaml.v2"
)

var fileReaderInject = ioutil.ReadFile
var fileReaderInject = os.ReadFile

type Publisher struct {
ID string `yaml:"id"`
Expand Down
3 changes: 1 addition & 2 deletions git/repo_activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package git

import (
"errors"
"io/ioutil"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -242,7 +241,7 @@ func extractOldestCommitDate(cIter object.CommitIter) time.Time {
}

func ranges(name string, value float64) float64 {
data, err := ioutil.ReadFile("vitality-ranges.yml")
data, err := os.ReadFile("vitality-ranges.yml")
if err != nil {
log.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ require (
gopkg.in/warnings.v0 v0.1.2 // indirect
)

go 1.18
go 1.21
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,7 @@ golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o=
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down

0 comments on commit cd2cc02

Please sign in to comment.