Skip to content

Commit 9f71a49

Browse files
authored
ci: Test with Go 1.23 and 1.24 (#502)
In CI, test with Go 1.23 and 1.24, and upgrade the Hermit-managed Go and golangci-lint to latest versions. The new golangci-lint had a number of warnings and minor issues that were either fixed or opted-out of.
1 parent cab639a commit 9f71a49

File tree

13 files changed

+24
-34
lines changed

13 files changed

+24
-34
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
matrix:
1414
# These are the release channels.
1515
# Hermit will handle installing the right patch.
16-
go: ["1.20", "1.21"]
16+
go: ["1.23", "1.24"]
1717
steps:
1818
- name: Checkout code
1919
uses: actions/checkout@v4
@@ -35,7 +35,7 @@ jobs:
3535
matrix:
3636
# These are versions for GitHub's setup-go.
3737
# '.x' will pick the latest patch release.
38-
go: ["1.20.x", "1.21.x"]
38+
go: ["1.23.x", "1.24.x"]
3939
steps:
4040
- name: Checkout code
4141
uses: actions/checkout@v4

.golangci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ linters:
1212
- wsl
1313
- funlen
1414
- gocognit
15-
- gomnd
1615
- goprintffuncname
1716
- paralleltest
1817
- nlreturn
@@ -36,13 +35,14 @@ linters:
3635
- nilnil
3736
- depguard # nothing to guard against yet
3837
- tagalign # hurts readability of kong tags
38+
- tenv # deprecated since v1.64, but not removed yet
3939
- mnd
4040
- perfsprint
4141
- err113
4242
- copyloopvar
4343
- intrange
44-
- execinquery
4544
- nakedret
45+
- recvcheck # value receivers are intentionally used for copies
4646

4747
linters-settings:
4848
govet:
File renamed without changes.
File renamed without changes.

bin/go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.go-1.23.6.pkg
1+
.go-1.24.0.pkg

bin/gofmt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.go-1.23.6.pkg
1+
.go-1.24.0.pkg

bin/golangci-lint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.golangci-lint-1.60.1.pkg
1+
.golangci-lint-1.64.5.pkg

config_test.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ func TestMultipleConfigLoading(t *testing.T) {
1515
}
1616

1717
cli.Flag = "first"
18-
first, cleanFirst := makeConfig(t, &cli)
19-
defer cleanFirst()
18+
first := makeConfig(t, &cli)
2019

2120
cli.Flag = ""
22-
second, cleanSecond := makeConfig(t, &cli)
23-
defer cleanSecond()
21+
second := makeConfig(t, &cli)
2422

2523
p := mustNew(t, &cli, kong.Configuration(kong.JSON, first, second))
2624
_, err := p.Parse(nil)
@@ -34,20 +32,19 @@ func TestConfigValidation(t *testing.T) {
3432
}
3533

3634
cli.Flag = "invalid"
37-
conf, cleanConf := makeConfig(t, &cli)
38-
defer cleanConf()
35+
conf := makeConfig(t, &cli)
3936

4037
p := mustNew(t, &cli, kong.Configuration(kong.JSON, conf))
4138
_, err := p.Parse(nil)
4239
assert.Error(t, err)
4340
}
4441

45-
func makeConfig(t *testing.T, config any) (path string, cleanup func()) {
42+
func makeConfig(t *testing.T, config any) (path string) {
4643
t.Helper()
47-
w, err := os.CreateTemp("", "")
44+
w, err := os.CreateTemp(t.TempDir(), "")
4845
assert.NoError(t, err)
4946
defer w.Close()
5047
err = json.NewEncoder(w).Encode(config)
5148
assert.NoError(t, err)
52-
return w.Name(), func() { os.Remove(w.Name()) }
49+
return w.Name()
5350
}

help.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ func (h *helpWriter) Write(w io.Writer) error {
415415

416416
func (h *helpWriter) Wrap(text string) {
417417
w := bytes.NewBuffer(nil)
418-
doc.ToText(w, strings.TrimSpace(text), "", " ", h.width)
418+
doc.ToText(w, strings.TrimSpace(text), "", " ", h.width) //nolint:staticcheck // cross-package links not possible
419419
for _, line := range strings.Split(strings.TrimSpace(w.String()), "\n") {
420420
h.Print(line)
421421
}
@@ -470,7 +470,7 @@ func writeTwoColumns(w *helpWriter, rows [][2]string) {
470470

471471
for _, row := range rows {
472472
buf := bytes.NewBuffer(nil)
473-
doc.ToText(buf, row[1], "", strings.Repeat(" ", defaultIndent), w.width-leftSize-defaultColumnPadding)
473+
doc.ToText(buf, row[1], "", strings.Repeat(" ", defaultIndent), w.width-leftSize-defaultColumnPadding) //nolint:staticcheck // cross-package links not possible
474474
lines := strings.Split(strings.TrimRight(buf.String(), "\n"), "\n")
475475

476476
line := fmt.Sprintf("%-*s", leftSize, row[0])

help_test.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ func TestHelp(t *testing.T) {
8383

8484
Three threeArg `arg help:"Sub-sub-arg."`
8585

86-
Four struct {
87-
} `cmd help:"Sub-sub-command."`
86+
Four struct{} `cmd help:"Sub-sub-command."`
8887
} `cmd help:"Another subcommand."`
8988
}
9089

@@ -192,8 +191,7 @@ func TestFlagsLast(t *testing.T) {
192191

193192
Three threeArg `arg help:"Sub-sub-arg."`
194193

195-
Four struct {
196-
} `cmd help:"Sub-sub-command."`
194+
Four struct{} `cmd help:"Sub-sub-command."`
197195
} `cmd help:"Another subcommand."`
198196
}
199197

@@ -296,8 +294,7 @@ func TestHelpTree(t *testing.T) {
296294
Two struct {
297295
Three threeArg `arg help:"Sub-sub-arg."`
298296

299-
Four struct {
300-
} `cmd help:"Sub-sub-command." aliases:"for,fore"`
297+
Four struct{} `cmd help:"Sub-sub-command." aliases:"for,fore"`
301298
} `cmd help:"Another subcommand."`
302299
}
303300

@@ -390,8 +387,7 @@ func TestHelpCompactNoExpand(t *testing.T) {
390387
Two struct {
391388
Three threeArg `arg help:"Sub-sub-arg."`
392389

393-
Four struct {
394-
} `cmd help:"Sub-sub-command." aliases:"for,fore"`
390+
Four struct{} `cmd help:"Sub-sub-command." aliases:"for,fore"`
395391
} `cmd help:"Another subcommand."`
396392
}
397393

@@ -603,7 +599,7 @@ func TestAutoGroup(t *testing.T) {
603599
if node, ok := parent.(*kong.Node); ok {
604600
return &kong.Group{
605601
Key: node.Name,
606-
Title: strings.Title(node.Name) + " flags:",
602+
Title: strings.Title(node.Name) + " flags:", //nolint:staticcheck // strings.Title in test is okay
607603
}
608604
}
609605
return nil

0 commit comments

Comments
 (0)