Update golang to 1.20 (#316)

* Update golang to 1.20

* Fix workflow file to make it work on `1.20`

* Update fieldalignment to 0.24.0

* Remove depricated ioutils

ioutils was depricatd and removed, same API available at `os` and `io`
packages now.
This commit is contained in:
Dmitry Kropachev
2025-04-25 13:34:40 -04:00
committed by GitHub
parent 439a1ba517
commit 643d2e775e
6 changed files with 23 additions and 16 deletions

View File

@@ -7,30 +7,39 @@ on:
pull_request: pull_request:
types: [opened, synchronize, reopened] types: [opened, synchronize, reopened]
env:
# On CICD following error shows up:
# go: github.com/gocql/gocql@v1.7.0: GOPROXY list is not the empty string, but contains no entries
# This env variable is set to make it go away
# If at some point you see no error, feel free to remove it
GOPROXY: direct
# On CICD following error shows up:
# go: golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@v0.24.0: golang.org/x/tools@v0.24.0: verifying module: missing GOSUMDB
# This env variable makes it go away
# If at some point you see no error, feel free to remove it
GOSUMDB: off
jobs: jobs:
build: build:
name: Build name: Build
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
SCYLLA_IMAGE: scylladb/scylla
steps: steps:
- name: Git Checkout - name: Git Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: '0' fetch-depth: '0'
- name: Install Go 1.17
- name: Install Go 1.20
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version: 1.17 go-version: "1.20"
- name: Cache Dependencies - name: Cache Dependencies
uses: actions/cache@v4 uses: actions/cache@v4
id: gomod-cache id: gomod-cache
with: with:
path: ~/go/pkg/mod path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('go.mod') }} key: ${{ runner.os }}-go-${{ hashFiles('go.mod', 'cmd/schemagen/testdata/go.mod') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download Dependencies - name: Download Dependencies
run: git --version && make get-deps && make get-tools run: git --version && make get-deps && make get-tools

View File

@@ -25,7 +25,7 @@ GOOS := $(shell uname | tr '[:upper:]' '[:lower:]')
GOARCH := $(shell go env GOARCH) GOARCH := $(shell go env GOARCH)
GOLANGCI_VERSION := 1.64.8 GOLANGCI_VERSION := 1.64.8
FIELDALIGNMENT_VERSION := 0.11.0 FIELDALIGNMENT_VERSION := 0.24.0
ifeq ($(GOARCH),arm64) ifeq ($(GOARCH),arm64)
GOLANGCI_DOWNLOAD_URL := "https://github.com/golangci/golangci-lint/releases/download/v$(GOLANGCI_VERSION)/golangci-lint-$(GOLANGCI_VERSION)-$(GOOS)-arm64.tar.gz" GOLANGCI_DOWNLOAD_URL := "https://github.com/golangci/golangci-lint/releases/download/v$(GOLANGCI_VERSION)/golangci-lint-$(GOLANGCI_VERSION)-$(GOOS)-arm64.tar.gz"

View File

@@ -3,7 +3,6 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"strings" "strings"
"testing" "testing"
@@ -32,17 +31,17 @@ func TestSchemagen(t *testing.T) {
const goldenFile = "testdata/models.go" const goldenFile = "testdata/models.go"
if *flagUpdate { if *flagUpdate {
if err := ioutil.WriteFile(goldenFile, b, os.ModePerm); err != nil { if err := os.WriteFile(goldenFile, b, os.ModePerm); err != nil {
t.Fatal(err) t.Fatal(err)
} }
} }
golden, err := ioutil.ReadFile(goldenFile) golden, err := os.ReadFile(goldenFile)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if diff := cmp.Diff(string(golden), string(b)); diff != "" { if diff := cmp.Diff(string(golden), string(b)); diff != "" {
t.Fatalf(diff) t.Fatal(diff)
} }
} }

View File

@@ -1,6 +1,6 @@
module schemagentest module schemagentest
go 1.17 go 1.20
require ( require (
github.com/gocql/gocql v1.7.0 github.com/gocql/gocql v1.7.0

2
go.mod
View File

@@ -1,6 +1,6 @@
module github.com/scylladb/gocqlx/v3 module github.com/scylladb/gocqlx/v3
go 1.17 go 1.20
require ( require (
github.com/gocql/gocql v1.7.0 github.com/gocql/gocql v1.7.0

View File

@@ -10,7 +10,6 @@ import (
"fmt" "fmt"
"io" "io"
"io/fs" "io/fs"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
@@ -208,7 +207,7 @@ func applyMigration(ctx context.Context, session gocqlx.Session, f fs.FS, path s
return err return err
} }
b, err := ioutil.ReadAll(file) b, err := io.ReadAll(file)
file.Close() file.Close()
if err != nil { if err != nil {
return err return err