Skip to content

Commit b1c25cc

Browse files
committed
bump golang to 1.23, golangci-lint to v2, fix errors
Signed-off-by: Avi Deitcher <[email protected]>
1 parent b74a4f7 commit b1c25cc

File tree

12 files changed

+32
-33
lines changed

12 files changed

+32
-33
lines changed

.github/workflows/ci.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010

11-
- name: Set up Go 1.19
12-
uses: actions/setup-go@v3
11+
- name: Set up Go 1.23
12+
uses: actions/setup-go@v5
1313
with:
14-
go-version: 1.19.2
14+
go-version: 1.23.4
1515
id: go
1616

1717
- name: Set path
@@ -44,14 +44,14 @@ jobs:
4444
runs-on: ubuntu-latest
4545
steps:
4646

47-
- name: Set up Go 1.19
48-
uses: actions/setup-go@v3
47+
- name: Set up Go 1.23
48+
uses: actions/setup-go@v5
4949
with:
50-
go-version: 1.19.2
50+
go-version: 1.23.4
5151
id: go
5252

5353
- name: Check out code
54-
uses: actions/checkout@v3
54+
uses: actions/checkout@v4
5555

5656
- name: build
5757
id: build

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ endif
6262

6363
.PHONY: install-deps
6464
install-deps:
65-
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1
65+
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.2
6666
go install github.com/gordonklaus/ineffassign@latest
6767

6868
.PHONY: test

cmd/compare.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"encoding/csv"
1919
"encoding/json"
2020
"fmt"
21-
"io/ioutil"
2221
"os"
2322
"strings"
2423
"text/tabwriter"
@@ -55,13 +54,13 @@ func compare(_ *cobra.Command, args []string) error {
5554

5655
var summaries []local.Summary
5756
for _, fileName := range args {
58-
data, err := ioutil.ReadFile(fileName)
57+
data, err := os.ReadFile(fileName)
5958
if err != nil {
6059
return err
6160
}
6261
var s local.Summary
6362
if err := json.Unmarshal(data, &s); err != nil {
64-
return fmt.Errorf("Failed to unmarshal %s: %v", fileName, err)
63+
return fmt.Errorf("failed to unmarshal %s: %v", fileName, err)
6564
}
6665
summaries = append(summaries, s)
6766
}
@@ -74,7 +73,7 @@ func compare(_ *cobra.Command, args []string) error {
7473
heading := []string{"Name"}
7574
if !csvCompare {
7675
heading = append(heading, args...)
77-
fmt.Fprintln(tw, strings.Join(heading, "\t"))
76+
_, _ = fmt.Fprintln(tw, strings.Join(heading, "\t"))
7877
} else {
7978
ids := []string{"ID"}
8079
starts := []string{"Start Time"}
@@ -101,7 +100,7 @@ func compare(_ *cobra.Command, args []string) error {
101100
for j := range summaries {
102101
r := summaries[j].Results[i]
103102
if r.Name != name {
104-
return fmt.Errorf("List of results for %s don't match %s: %s != %s", args[0], args[j], r.Name, name)
103+
return fmt.Errorf("list of results for %s don't match %s: %s != %s", args[0], args[j], r.Name, name)
105104
}
106105

107106
resStr := r.TestResult.Sprintf("%s (%s)",
@@ -112,14 +111,14 @@ func compare(_ *cobra.Command, args []string) error {
112111
results = append(results, resStr)
113112
}
114113
if !csvCompare {
115-
fmt.Fprintln(tw, strings.Join(results, "\t"))
114+
_, _ = fmt.Fprintln(tw, strings.Join(results, "\t"))
116115
} else {
117116
if err := cw.Write(results); err != nil {
118117
return err
119118
}
120119
}
121120
}
122-
tw.Flush()
121+
_ = tw.Flush()
123122
cw.Flush()
124123
return nil
125124
}

cmd/info.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func info(_ *cobra.Command, _ []string) error {
5454

5555
lst := p.List(config)
5656
if !csvInfo {
57-
fmt.Fprintf(tw, "NAME\tDESCRIPTION\n")
57+
_, _ = fmt.Fprintf(tw, "NAME\tDESCRIPTION\n")
5858
} else {
5959
heading := []string{"Name", "Description", "Known issues"}
6060
if err := cw.Write(heading); err != nil {
@@ -64,15 +64,15 @@ func info(_ *cobra.Command, _ []string) error {
6464

6565
for _, i := range lst {
6666
if !csvInfo {
67-
fmt.Fprintf(tw, "%s\t%s\n", i.Name, i.Summary)
67+
_, _ = fmt.Fprintf(tw, "%s\t%s\n", i.Name, i.Summary)
6868
} else {
6969
out := []string{i.Name, i.Summary, i.Issue}
7070
if err := cw.Write(out); err != nil {
7171
return nil
7272
}
7373
}
7474
}
75-
tw.Flush()
75+
_ = tw.Flush()
7676
cw.Flush()
7777
return nil
7878
}

cmd/list.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ func list(_ *cobra.Command, args []string) error {
6363
w.Init(os.Stdout, 0, 8, 0, '\t', 0)
6464

6565
lst := p.List(config)
66-
fmt.Fprint(w, "STATE\tTEST\tLABELS\n")
66+
_, _ = fmt.Fprint(w, "STATE\tTEST\tLABELS\n")
6767
for _, i := range lst {
6868
state := i.TestResult.Sprintf(local.TestResultNames[i.TestResult])
69-
fmt.Fprintf(w, "%s\t%s\t%s\n", state, i.Name, i.LabelString())
69+
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\n", state, i.Name, i.LabelString())
7070
}
71-
w.Flush()
71+
_ = w.Flush()
7272
return nil
7373
}

cmd/run.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func run(cmd *cobra.Command, args []string) error {
148148
if err != nil {
149149
return err
150150
}
151-
defer tf.Close()
151+
defer func() { _ = tf.Close() }()
152152

153153
tCsv := csv.NewWriter(tf)
154154
if err = tCsv.Write(testCsvFields); err != nil {
@@ -159,7 +159,7 @@ func run(cmd *cobra.Command, args []string) error {
159159
if err != nil {
160160
return err
161161
}
162-
defer sf.Close()
162+
defer func() { _ = sf.Close() }()
163163

164164
sCsv := csv.NewWriter(sf)
165165

@@ -288,7 +288,7 @@ func run(cmd *cobra.Command, args []string) error {
288288
log.Log(logger.LevelSummary, fmt.Sprintf("Duration: %.2fs", duration.Seconds()))
289289

290290
if failed > 0 {
291-
return fmt.Errorf("Some tests failed")
291+
return fmt.Errorf("some tests failed")
292292
}
293293
return nil
294294
}

local/labels.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func NewRunConfig(labels string, pattern string) RunConfig {
103103
// ValidatePattern validates that an arg string is a valid test pattern
104104
func ValidatePattern(args []string) (string, error) {
105105
if len(args) > 1 {
106-
return "", fmt.Errorf("Expected only one test pattern")
106+
return "", fmt.Errorf("expected only one test pattern")
107107
}
108108
if len(args) == 0 {
109109
return "", nil

local/parser.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func ParseTags(file string) (*Tags, error) {
4343
if err != nil {
4444
return nil, err
4545
}
46-
defer f.Close()
46+
defer func() { _ = f.Close() }()
4747

4848
tags := &Tags{}
4949
scanner := bufio.NewScanner(f)
@@ -80,7 +80,7 @@ func ParseTags(file string) (*Tags, error) {
8080
}
8181
} else {
8282
if v.String() != "" {
83-
return nil, fmt.Errorf("Field %s specified multiple times", rt)
83+
return nil, fmt.Errorf("field %s specified multiple times", rt)
8484
}
8585
v.SetString(tagValue)
8686
}

local/script.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func executeScript(script, cwd, name string, args []string, config RunConfig) (R
6161
}
6262
}
6363
if executable == "" {
64-
return Result{}, fmt.Errorf("Can't find a suitable shell to execute %s", script)
64+
return Result{}, fmt.Errorf("can't find a suitable shell to execute %s", script)
6565
}
6666
cmdArgs = append(cmdArgs, script)
6767
cmdArgs = append(cmdArgs, args...)

local/test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (t *Test) Init() error {
3737
t.Summary = tags.Summary
3838
order, name := getNameAndOrder(filepath.Base(t.Path))
3939
if t.Parent == nil {
40-
return fmt.Errorf("A test should have a parent group")
40+
return fmt.Errorf("a test should have a parent group")
4141
}
4242
t.Tags.Name = fmt.Sprintf("%s.%s", t.Parent.Name(), name)
4343
t.Labels, t.NotLabels = ParseLabels(t.Tags.Labels)
@@ -129,7 +129,7 @@ func (t *Test) Run(config RunConfig) ([]Result, error) {
129129
if t.Parent.PreTestPath != "" {
130130
res, err := executeScript(t.Parent.PreTestPath, t.Path, name, []string{name}, config)
131131
if res.TestResult != Pass {
132-
return results, fmt.Errorf("Error running: %s. %s", t.Parent.PreTestPath, err.Error())
132+
return results, fmt.Errorf("error running: %s. %s", t.Parent.PreTestPath, err.Error())
133133
}
134134
}
135135
// Run the test
@@ -156,7 +156,7 @@ func (t *Test) Run(config RunConfig) ([]Result, error) {
156156
if t.Parent.PostTestPath != "" {
157157
res, err := executeScript(t.Parent.PostTestPath, t.Path, name, []string{name, fmt.Sprintf("%d", res.TestResult)}, config)
158158
if res.TestResult != Pass {
159-
return results, fmt.Errorf("Error running: %s. %s", t.Parent.PostTestPath, err.Error())
159+
return results, fmt.Errorf("error running: %s. %s", t.Parent.PostTestPath, err.Error())
160160
}
161161
}
162162
res.Test = t

logger/logger_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func TestFileLogger(t *testing.T) {
1111
if err != nil {
1212
t.Fatal(err)
1313
}
14-
defer f.Close()
14+
defer func() { _ = f.Close() }()
1515

1616
l := NewFileLogger(f)
1717
l.SetLevel(LevelDebug)

sysinfo/sysinfo_linux.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func getPlatformSpecifics(info SystemInfo) SystemInfo {
4242
v := strings.TrimSpace(fs[1])
4343

4444
if k == "MemTotal" {
45-
v = strings.Replace(v, " kB", "", -1)
45+
v = strings.ReplaceAll(v, " kB", "")
4646
n, _ := strconv.ParseInt(v, 10, 64)
4747
info.Memory = n * 1024
4848
break

0 commit comments

Comments
 (0)