Skip to content

Commit dc79381

Browse files
authored
chore: bump go version to 1.22 (#1112)
* chore: bump go version to 1.22 * chore: GA action * chore: move all jobs to single job * chore: remove drone * chore: golangci-lint upgrade, fix lint error * chore: merge workflows
1 parent 0afdd23 commit dc79381

File tree

13 files changed

+80
-94
lines changed

13 files changed

+80
-94
lines changed

.drone.yml

Lines changed: 0 additions & 75 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
12+
env:
13+
GOLANGCI_LINT_VERSION: v1.61.0
14+
15+
jobs:
16+
lint-build-test:
17+
name: Lint, Build, and Test
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup go
24+
uses: actions/setup-go@v5
25+
with:
26+
go-version-file: ./go.mod
27+
28+
- name: Run golangci-lint
29+
uses: golangci/golangci-lint-action@v6
30+
with:
31+
version: ${{env.GOLANGCI_LINT_VERSION}}
32+
args: |
33+
"./..." --timeout=7m
34+
skip-cache: true
35+
install-mode: binary
36+
37+
- name: Setup Mage
38+
uses: magefile/mage-action@v3
39+
with:
40+
install-only: true
41+
42+
- name: Build
43+
run: |
44+
mage -v build
45+
46+
- name: Install test dependencies
47+
run: |
48+
sudo apt update
49+
sudo apt install -y gcc
50+
51+
- name: Test
52+
run: |
53+
CGO_ENABLED=1 mage -v testRace

.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

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/grafana/grafana-plugin-sdk-go
22

3-
go 1.21
3+
go 1.22
44

55
require (
66
github.com/apache/arrow/go/v15 v15.0.2

0 commit comments

Comments
 (0)