Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update go, linter versions and update dependencies #251

Merged
merged 4 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
go: ['1.13.x', '1.14.x', '1.15.x', '1.16.x', '1.17.x']
go: ['1.21.x', '1.22.x', '1.23.x']
steps:

- name: Set up Go
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.21"
go-version: "1.23"
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.55.1
version: v1.62.2
23 changes: 16 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
service:
golangci-lint-version: v1.55.1

run:
tests: false
skip-dirs:

issues:
exclude-files:
- ".*easyjson\\.go$"
exclude-dirs:
- allure
- mocks
skip-files:
- ".*easyjson\\.go$"

output:
print-issued-lines: false

Expand All @@ -32,6 +32,14 @@ linters-settings:
# Should be enabled after fixing underscore package names.
- name: var-naming
disabled: true
gci:
sections:
- standard
- default
- prefix(github.com/lamoda/gonkey)
skip-generated: true
custom-order: false
no-lex-order: false

linters:
enable:
Expand All @@ -58,4 +66,5 @@ linters:
- unconvert
- unparam
- unused
- gas
- gosec
- gci
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.14 as build
FROM golang:1.23 as build

ENV GOOS linux
ENV GOARCH amd64
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ test:
go test ./...

lint:
docker run --rm -v $(PWD):/app -w /app golangci/golangci-lint:v1.55.1 golangci-lint run -v
docker run --rm -v $(PWD):/app -w /app golangci/golangci-lint:v1.62.2 golangci-lint run -v
2 changes: 1 addition & 1 deletion README-ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ import (
"github.com/lamoda/gonkey/fixtures"
redisLoader "github.com/lamoda/gonkey/fixtures/redis"
// redisLoader "custom_module/gonkey-redis" // внешняя библиотека, содержащая реализацию интерфейса fixtures.Loader
redisClient "github.com/go-redis/redis/v9"
redisClient "github.com/redis/go-redis/v9"
"github.com/lamoda/gonkey/runner"
)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ import (
"github.com/lamoda/gonkey/fixtures"
redisLoader "github.com/lamoda/gonkey/fixtures/redis"
// redisLoader "custom_module/gonkey-redis" // custom implementation of a fixtures.Loader interface
redisClient "github.com/go-redis/redis/v9"
redisClient "github.com/redis/go-redis/v9"
"github.com/lamoda/gonkey/runner"
)

Expand Down
6 changes: 3 additions & 3 deletions checker/addons/openapi2_compliance/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"encoding/json"
"strings"

"github.com/lamoda/gonkey/checker"
"github.com/lamoda/gonkey/models"

"github.com/go-openapi/errors"
"github.com/go-openapi/loads"
"github.com/go-openapi/spec"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/validate"

"github.com/lamoda/gonkey/checker"
"github.com/lamoda/gonkey/models"
)

type ResponseSchemaChecker struct {
Expand Down
6 changes: 3 additions & 3 deletions checker/response_db/response_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"fmt"
"strings"

"github.com/fatih/color"
"github.com/kylelemons/godebug/pretty"

"github.com/lamoda/gonkey/checker"
"github.com/lamoda/gonkey/compare"
"github.com/lamoda/gonkey/models"

"github.com/fatih/color"
"github.com/kylelemons/godebug/pretty"
)

type ResponseDbChecker struct {
Expand Down
4 changes: 2 additions & 2 deletions checker/response_header/response_header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"sort"
"testing"

"github.com/stretchr/testify/assert"

"github.com/lamoda/gonkey/models"
"github.com/lamoda/gonkey/testloader/yaml_file"

"github.com/stretchr/testify/assert"
)

func TestCheckShouldMatchSubset(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions examples/mock-based-on-request/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
urlpkg "net/url"
Expand Down Expand Up @@ -45,7 +44,7 @@ func Do(w http.ResponseWriter, r *http.Request) {
if res.StatusCode != http.StatusOK {
return 0, fmt.Errorf("backend response status code %d", res.StatusCode)
}
body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
_ = res.Body.Close()
if err != nil {
return 0, fmt.Errorf("cannot read response body %w", err)
Expand Down
4 changes: 2 additions & 2 deletions examples/mock-field-json-str/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
Expand All @@ -20,7 +20,7 @@ func initServer() {
}

func ProxyRequest(w http.ResponseWriter, r *http.Request) {
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
log.Print(err)
w.Write([]byte("{\"status\": \"error\"}"))
Expand Down
4 changes: 2 additions & 2 deletions examples/traffic-lights-demo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"sync"
Expand Down Expand Up @@ -54,7 +54,7 @@ func initServer() {
lights.mutex.Lock()
defer lights.mutex.Unlock()

request, err := ioutil.ReadAll(r.Body)
request, err := io.ReadAll(r.Body)
if err != nil {
log.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions examples/with-cases-example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
)
Expand Down Expand Up @@ -34,7 +34,7 @@ func Do(w http.ResponseWriter, r *http.Request) {
return
}

jsonRequest, _ := ioutil.ReadAll(r.Body)
jsonRequest, _ := io.ReadAll(r.Body)
request := buildRequest(jsonRequest)

if request.Name == "a" {
Expand Down
3 changes: 1 addition & 2 deletions fixtures/aerospike/aerospike.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"

"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -91,7 +90,7 @@ func (l *LoaderAerospike) loadFile(name string, ctx *loadContext) error {
if l.debug {
fmt.Println("Loading", file)
}
data, err := ioutil.ReadFile(file)
data, err := os.ReadFile(file)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions fixtures/aerospike/aerospike_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package aerospike

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

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -114,7 +114,7 @@ func TestLoaderAerospike_loadYml(t *testing.T) {
}

func loadTestData(t *testing.T, path string) []byte {
aerospikeYaml, err := ioutil.ReadFile(path)
aerospikeYaml, err := os.ReadFile(path)
if err != nil {
t.Error("No aerospike.yaml")
}
Expand Down
3 changes: 1 addition & 2 deletions fixtures/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"regexp"
"sort"
Expand Down Expand Up @@ -100,7 +99,7 @@ func (l *LoaderMysql) loadFile(name string, ctx *loadContext) error {

l.printDebug("Loading", file)

data, err := ioutil.ReadFile(file)
data, err := os.ReadFile(file)
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions fixtures/mysql/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"database/sql"
"database/sql/driver"
"fmt"
"io/ioutil"
"os"
"strings"
"testing"

Expand All @@ -15,7 +15,7 @@ import (

func TestBuildInsertQuery(t *testing.T) {

ymlFile, err := ioutil.ReadFile("../testdata/sql.yaml")
ymlFile, err := os.ReadFile("../testdata/sql.yaml")
require.NoError(t, err)

expected := []string{
Expand Down Expand Up @@ -45,7 +45,7 @@ func TestBuildInsertQuery(t *testing.T) {
}

func TestLoadTablesShouldResolveRefs(t *testing.T) {
yml, err := ioutil.ReadFile("../testdata/sql_refs.yaml")
yml, err := os.ReadFile("../testdata/sql_refs.yaml")
require.NoError(t, err)

db, mock, err := sqlmock.New()
Expand Down Expand Up @@ -111,7 +111,7 @@ func TestLoadTablesShouldResolveRefs(t *testing.T) {
}

func TestLoadTablesShouldExtendRows(t *testing.T) {
yml, err := ioutil.ReadFile("../testdata/sql_extend.yaml")
yml, err := os.ReadFile("../testdata/sql_extend.yaml")
require.NoError(t, err)

db, mock, err := sqlmock.New()
Expand Down
7 changes: 3 additions & 4 deletions fixtures/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"regexp"
"sort"
Expand Down Expand Up @@ -117,7 +116,7 @@ func (f *LoaderPostgres) loadFile(name string, ctx *loadContext) error {
if f.debug {
fmt.Println("Loading", file)
}
data, err := ioutil.ReadFile(file)
data, err := os.ReadFile(file)
if err != nil {
return err
}
Expand Down Expand Up @@ -380,7 +379,7 @@ func (f *LoaderPostgres) buildInsertQuery(ctx *loadContext, t tableName, rows ta
fieldPresence := make(map[string]bool)
for _, row := range rows {
for name := range row {
if len(name) > 0 && name[0] == '$' {
if name != "" && name[0] == '$' {
continue
}
if _, ok := fieldPresence[name]; !ok {
Expand All @@ -403,7 +402,7 @@ func (f *LoaderPostgres) buildInsertQuery(ctx *loadContext, t tableName, rows ta
}
// resolve references
if stringValue, ok := value.(string); ok {
if len(stringValue) > 0 && stringValue[0] == '$' {
if stringValue != "" && stringValue[0] == '$' {
var err error
dbValuesRow[k], err = f.resolveExpression(stringValue, ctx)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions fixtures/postgres/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package postgres

import (
"database/sql"
"io/ioutil"
"os"
"testing"

"github.com/stretchr/testify/require"
"gopkg.in/DATA-DOG/go-sqlmock.v1"
)

func TestBuildInsertQuery(t *testing.T) {
yml, err := ioutil.ReadFile("../testdata/sql.yaml")
yml, err := os.ReadFile("../testdata/sql.yaml")
require.NoError(t, err)

expected := "INSERT INTO \"public\".\"table\" AS row (\"field1\", \"field2\", \"field3\", \"field4\", \"field5\") VALUES " +
Expand All @@ -36,7 +36,7 @@ func TestBuildInsertQuery(t *testing.T) {
}

func TestLoadTablesShouldResolveSchema(t *testing.T) {
yml, err := ioutil.ReadFile("../testdata/sql_schema.yaml")
yml, err := os.ReadFile("../testdata/sql_schema.yaml")
require.NoError(t, err)

db, mock, err := sqlmock.New()
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestLoadTablesShouldResolveSchema(t *testing.T) {
}

func TestLoadTablesShouldResolveRefs(t *testing.T) {
yml, err := ioutil.ReadFile("../testdata/sql_refs.yaml")
yml, err := os.ReadFile("../testdata/sql_refs.yaml")
require.NoError(t, err)

db, mock, err := sqlmock.New()
Expand Down Expand Up @@ -166,7 +166,7 @@ func TestLoadTablesShouldResolveRefs(t *testing.T) {
}

func TestLoadTablesShouldExtendRows(t *testing.T) {
yml, err := ioutil.ReadFile("../testdata/sql_extend.yaml")
yml, err := os.ReadFile("../testdata/sql_extend.yaml")
require.NoError(t, err)

db, mock, err := sqlmock.New()
Expand Down
4 changes: 2 additions & 2 deletions fixtures/redis/parser/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package parser
import (
"errors"
"fmt"
"io/ioutil"
"os"

"gopkg.in/yaml.v3"
)
Expand Down Expand Up @@ -466,7 +466,7 @@ func (p *redisYamlParser) buildZSets(ctx *Context, data *ZSets) error {
}

func (p *redisYamlParser) Parse(ctx *Context, filename string) (*Fixture, error) {
data, err := ioutil.ReadFile(filename)
data, err := os.ReadFile(filename)
if err != nil {
return nil, err
}
Expand Down
Loading
Loading