Skip to content

Commit 7ff63c4

Browse files
committed
chore: golangci-lint upgrade, fix lint error
1 parent 0204a7f commit 7ff63c4

File tree

12 files changed

+58
-27
lines changed

12 files changed

+58
-27
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ on:
77
pull_request:
88

99
jobs:
10-
build_lint_test:
10+
build-lint-test:
11+
name: CI
1112
runs-on: ubuntu-latest
1213
steps:
1314
- name: Checkout
@@ -16,7 +17,7 @@ jobs:
1617
- name: Setup go
1718
uses: actions/setup-go@v5
1819
with:
19-
go-version-file: go.mod
20+
go-version-file: ./go.mod
2021

2122
- name: Setup Mage
2223
uses: magefile/mage-action@v3
@@ -28,17 +29,10 @@ jobs:
2829
sudo apt update
2930
sudo apt install -y gcc
3031
31-
- name: Setup CI Linter
32-
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2
33-
3432
- name: Build
3533
run: |
3634
mage -v build
3735
38-
- name: Lint
39-
run: |
40-
mage -v lint
41-
4236
- name: Test
4337
run: |
4438
CGO_ENABLED=1 mage -v testRace

.github/workflows/go-lint.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Lint Go
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
11+
env:
12+
GOLANGCI_LINT_VERSION: v1.61.0
13+
jobs:
14+
lint-go:
15+
name: Lint Go
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version-file: ./go.mod
22+
- name: Run golangci-lint
23+
uses: golangci/golangci-lint-action@v6
24+
with:
25+
version: ${{env.GOLANGCI_LINT_VERSION}}
26+
args: |
27+
"./..." --timeout=7m
28+
skip-cache: true
29+
install-mode: binary

.golangci.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
[run]
2-
skip-files = ["data/.*\\.gen\\.go", "data/generic_nullable_vector\\.go", "data/generic_vector\\.go"]
1+
[issues]
2+
exclude-files = ["data/.*\\.gen\\.go", "data/generic_nullable_vector\\.go", "data/generic_vector\\.go"]
33

44
[linters-settings.golint]
55
min-confidence = 1
@@ -39,7 +39,7 @@ enable = [
3939
"misspell",
4040
"nakedret",
4141
"rowserrcheck",
42-
"exportloopref",
42+
"copyloopvar",
4343
"staticcheck",
4444
"stylecheck",
4545
"typecheck",
@@ -59,3 +59,8 @@ enable = [
5959
[[issues.exclude-rules]]
6060
linters = ["errorlint"]
6161
text = "non-wrapping format verb for fmt.Errorf"
62+
[[issues.exclude-rules]]
63+
linters = ["staticcheck"]
64+
text = "SA1019"
65+
[linters-settings.gosec]
66+
excludes = ["G115"]

backend/json.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package backend
22

33
import (
4-
"fmt"
4+
"errors"
55
"sort"
66
"unsafe"
77

@@ -166,7 +166,7 @@ func readDataResponseJSON(rsp *DataResponse, iter *jsoniter.Iterator) {
166166
for l2Field := iter.ReadObject(); l2Field != ""; l2Field = iter.ReadObject() {
167167
switch l2Field {
168168
case "error":
169-
rsp.Error = fmt.Errorf(iter.ReadString())
169+
rsp.Error = errors.New(iter.ReadString())
170170

171171
case "status":
172172
rsp.Status = Status(iter.ReadInt32())

data/frame_json_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ func readNullable{{.Type}}VectorJSON(iter *jsoniter.Iterator, size int) (*nullab
511511
tname := caser.String(tstr)
512512
tuppr := strings.ToUpper(tstr)
513513

514-
fmt.Printf(" case arrow." + tuppr + ":\n\t\tent = writeArrowData" + tname + "(stream, col)\n")
514+
fmt.Printf(" case arrow.%s:\n\t\tent = writeArrowData%s(stream, col)\n", tuppr, tname)
515515
}
516516

517517
for _, tstr := range types {
@@ -550,8 +550,8 @@ func readNullable{{.Type}}VectorJSON(iter *jsoniter.Iterator, size int) (*nullab
550550

551551
for _, tstr := range types {
552552
tname := caser.String(tstr)
553-
fmt.Printf(" case FieldType" + tname + ": return read" + tname + "VectorJSON(iter, size)\n")
554-
fmt.Printf(" case FieldTypeNullable" + tname + ": return readNullable" + tname + "VectorJSON(iter, size)\n")
553+
fmt.Printf(" case FieldType%s: return read%sVectorJSON(iter, size)\n", tname, tname)
554+
fmt.Printf(" case FieldTypeNullable%s: return readNullable%sVectorJSON(iter, size)\n", tname, tname)
555555
}
556556

557557
assert.FailNow(t, "fail so we see the output")

data/sqlutil/converter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ type Converter struct {
143143
func DefaultConverterFunc(t reflect.Type) func(in interface{}) (interface{}, error) {
144144
return func(in interface{}) (interface{}, error) {
145145
inType := reflect.TypeOf(in)
146-
if inType == reflect.PtrTo(t) {
146+
if inType == reflect.PointerTo(t) {
147147
n := reflect.ValueOf(in)
148148

149149
return n.Elem().Interface(), nil
@@ -180,7 +180,7 @@ func NewDefaultConverter(name string, nullable bool, t reflect.Type) Converter {
180180

181181
v := reflect.New(t)
182182
var fieldType data.FieldType
183-
if v.Type() == reflect.PtrTo(t) {
183+
if v.Type() == reflect.PointerTo(t) {
184184
v = v.Elem()
185185
fieldType = data.FieldTypeFor(v.Interface())
186186
} else {

data/sqlutil/converter_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func TestDefaultConverter(t *testing.T) {
173173
assert.Equal(t, reflect.TypeOf(value).String(), v.Type.String())
174174
} else {
175175
// nullable fields should not exactly match
176-
kind := reflect.PtrTo(v.Type).String()
176+
kind := reflect.PointerTo(v.Type).String()
177177
valueKind := reflect.TypeOf(value).String()
178178
if !strings.HasPrefix(kind, "*sql.Null") {
179179
assert.Equal(t, valueKind, kind)

data/time_series.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (t TimeSeriesType) String() string {
6666
func (f *Frame) TimeSeriesSchema() TimeSeriesSchema {
6767
var tsSchema TimeSeriesSchema
6868
tsSchema.Type = TimeSeriesTypeNot
69-
if f.Fields == nil || len(f.Fields) == 0 {
69+
if len(f.Fields) == 0 {
7070
return tsSchema
7171
}
7272

data/time_series_field_sort_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func TestSortWideFrameFields(t *testing.T) {
119119
require.NoError(t, err)
120120
if diff := cmp.Diff(tt.frameToSort, tt.afterSort, FrameTestCompareOptions()...); diff != "" {
121121
t.Errorf("Result mismatch (-want +got):\n%s", diff)
122-
t.Logf(tt.frameToSort.StringTable(-1, -1))
122+
t.Log(tt.frameToSort.StringTable(-1, -1))
123123
}
124124
})
125125
}
@@ -210,7 +210,7 @@ func TestSortWideFrameFields_MixedLabels(t *testing.T) {
210210
require.NoError(t, err)
211211
if diff := cmp.Diff(tt.frameToSort, tt.afterSort, FrameTestCompareOptions()...); diff != "" {
212212
t.Errorf("Result mismatch (-want +got):\n%s", diff)
213-
t.Logf(tt.frameToSort.StringTable(-1, -1))
213+
t.Log(tt.frameToSort.StringTable(-1, -1))
214214
}
215215
})
216216
}

experimental/concurrent/concurrent.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package concurrent
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"net/http"
78

@@ -52,7 +53,7 @@ func QueryData(ctx context.Context, req *backend.QueryDataRequest, fn QueryDataF
5253
if theErr, ok := r.(error); ok {
5354
err = theErr
5455
} else if theErrString, ok := r.(string); ok {
55-
err = fmt.Errorf(theErrString)
56+
err = errors.New(theErrString)
5657
} else {
5758
err = fmt.Errorf("unexpected error - %w", err)
5859
}

experimental/e2e/config/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ func LoadConfig(path string) (*Config, error) {
7070
cfg.Address = "127.0.0.1:9999"
7171
}
7272

73-
if cfg.Storage == nil || len(cfg.Storage) == 0 {
73+
if len(cfg.Storage) == 0 {
7474
cfg.Storage = []*StorageConfig{{
7575
Type: StorageTypeHAR,
7676
Path: "fixtures/e2e.har",
7777
}}
7878
}
7979

80-
if cfg.Hosts == nil || len(cfg.Hosts) == 0 {
80+
if len(cfg.Hosts) == 0 {
8181
cfg.Hosts = make([]string, 0)
8282
}
8383

experimental/golden_response_checker.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package experimental
22

33
import (
44
"bufio"
5+
"errors"
6+
57
// ignoring the G505 so that the checksum matches git hash
68
// nolint:gosec
79
"crypto/sha1"
@@ -69,7 +71,7 @@ func CheckGoldenDataResponse(path string, dr *backend.DataResponse, updateFile b
6971
}
7072

7173
if len(errorString) > 0 {
72-
return errorAfterUpdate(fmt.Errorf(errorString), path, dr, updateFile)
74+
return errorAfterUpdate(errors.New(errorString), path, dr, updateFile)
7375
}
7476

7577
return nil // OK

0 commit comments

Comments
 (0)