diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3396e46..4483d4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: matrix: # These are the release channels. # Hermit will handle installing the right patch. - go: ["1.20", "1.21"] + go: ["1.23", "1.24"] steps: - name: Checkout code uses: actions/checkout@v4 @@ -35,7 +35,7 @@ jobs: matrix: # These are versions for GitHub's setup-go. # '.x' will pick the latest patch release. - go: ["1.20.x", "1.21.x"] + go: ["1.23.x", "1.24.x"] steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/.golangci.yml b/.golangci.yml index 3a05633..1eb0b92 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -12,7 +12,6 @@ linters: - wsl - funlen - gocognit - - gomnd - goprintffuncname - paralleltest - nlreturn @@ -36,13 +35,14 @@ linters: - nilnil - depguard # nothing to guard against yet - tagalign # hurts readability of kong tags + - tenv # deprecated since v1.64, but not removed yet - mnd - perfsprint - err113 - copyloopvar - intrange - - execinquery - nakedret + - recvcheck # value receivers are intentionally used for copies linters-settings: govet: diff --git a/bin/.go-1.23.6.pkg b/bin/.go-1.24.0.pkg similarity index 100% rename from bin/.go-1.23.6.pkg rename to bin/.go-1.24.0.pkg diff --git a/bin/.golangci-lint-1.60.1.pkg b/bin/.golangci-lint-1.64.5.pkg similarity index 100% rename from bin/.golangci-lint-1.60.1.pkg rename to bin/.golangci-lint-1.64.5.pkg diff --git a/bin/go b/bin/go index 8fb1c41..42b4aa3 120000 --- a/bin/go +++ b/bin/go @@ -1 +1 @@ -.go-1.23.6.pkg \ No newline at end of file +.go-1.24.0.pkg \ No newline at end of file diff --git a/bin/gofmt b/bin/gofmt index 8fb1c41..42b4aa3 120000 --- a/bin/gofmt +++ b/bin/gofmt @@ -1 +1 @@ -.go-1.23.6.pkg \ No newline at end of file +.go-1.24.0.pkg \ No newline at end of file diff --git a/bin/golangci-lint b/bin/golangci-lint index 4857716..1bb9797 120000 --- a/bin/golangci-lint +++ b/bin/golangci-lint @@ -1 +1 @@ -.golangci-lint-1.60.1.pkg \ No newline at end of file +.golangci-lint-1.64.5.pkg \ No newline at end of file diff --git a/config_test.go b/config_test.go index 570f142..fd303af 100644 --- a/config_test.go +++ b/config_test.go @@ -15,12 +15,10 @@ func TestMultipleConfigLoading(t *testing.T) { } cli.Flag = "first" - first, cleanFirst := makeConfig(t, &cli) - defer cleanFirst() + first := makeConfig(t, &cli) cli.Flag = "" - second, cleanSecond := makeConfig(t, &cli) - defer cleanSecond() + second := makeConfig(t, &cli) p := mustNew(t, &cli, kong.Configuration(kong.JSON, first, second)) _, err := p.Parse(nil) @@ -34,20 +32,19 @@ func TestConfigValidation(t *testing.T) { } cli.Flag = "invalid" - conf, cleanConf := makeConfig(t, &cli) - defer cleanConf() + conf := makeConfig(t, &cli) p := mustNew(t, &cli, kong.Configuration(kong.JSON, conf)) _, err := p.Parse(nil) assert.Error(t, err) } -func makeConfig(t *testing.T, config any) (path string, cleanup func()) { +func makeConfig(t *testing.T, config any) (path string) { t.Helper() - w, err := os.CreateTemp("", "") + w, err := os.CreateTemp(t.TempDir(), "") assert.NoError(t, err) defer w.Close() err = json.NewEncoder(w).Encode(config) assert.NoError(t, err) - return w.Name(), func() { os.Remove(w.Name()) } + return w.Name() } diff --git a/help.go b/help.go index 6363ea2..28290f6 100644 --- a/help.go +++ b/help.go @@ -415,7 +415,7 @@ func (h *helpWriter) Write(w io.Writer) error { func (h *helpWriter) Wrap(text string) { w := bytes.NewBuffer(nil) - doc.ToText(w, strings.TrimSpace(text), "", " ", h.width) + doc.ToText(w, strings.TrimSpace(text), "", " ", h.width) //nolint:staticcheck // cross-package links not possible for _, line := range strings.Split(strings.TrimSpace(w.String()), "\n") { h.Print(line) } @@ -470,7 +470,7 @@ func writeTwoColumns(w *helpWriter, rows [][2]string) { for _, row := range rows { buf := bytes.NewBuffer(nil) - doc.ToText(buf, row[1], "", strings.Repeat(" ", defaultIndent), w.width-leftSize-defaultColumnPadding) + doc.ToText(buf, row[1], "", strings.Repeat(" ", defaultIndent), w.width-leftSize-defaultColumnPadding) //nolint:staticcheck // cross-package links not possible lines := strings.Split(strings.TrimRight(buf.String(), "\n"), "\n") line := fmt.Sprintf("%-*s", leftSize, row[0]) diff --git a/help_test.go b/help_test.go index e680be2..f8aebab 100644 --- a/help_test.go +++ b/help_test.go @@ -83,8 +83,7 @@ func TestHelp(t *testing.T) { Three threeArg `arg help:"Sub-sub-arg."` - Four struct { - } `cmd help:"Sub-sub-command."` + Four struct{} `cmd help:"Sub-sub-command."` } `cmd help:"Another subcommand."` } @@ -192,8 +191,7 @@ func TestFlagsLast(t *testing.T) { Three threeArg `arg help:"Sub-sub-arg."` - Four struct { - } `cmd help:"Sub-sub-command."` + Four struct{} `cmd help:"Sub-sub-command."` } `cmd help:"Another subcommand."` } @@ -296,8 +294,7 @@ func TestHelpTree(t *testing.T) { Two struct { Three threeArg `arg help:"Sub-sub-arg."` - Four struct { - } `cmd help:"Sub-sub-command." aliases:"for,fore"` + Four struct{} `cmd help:"Sub-sub-command." aliases:"for,fore"` } `cmd help:"Another subcommand."` } @@ -390,8 +387,7 @@ func TestHelpCompactNoExpand(t *testing.T) { Two struct { Three threeArg `arg help:"Sub-sub-arg."` - Four struct { - } `cmd help:"Sub-sub-command." aliases:"for,fore"` + Four struct{} `cmd help:"Sub-sub-command." aliases:"for,fore"` } `cmd help:"Another subcommand."` } @@ -603,7 +599,7 @@ func TestAutoGroup(t *testing.T) { if node, ok := parent.(*kong.Node); ok { return &kong.Group{ Key: node.Name, - Title: strings.Title(node.Name) + " flags:", + Title: strings.Title(node.Name) + " flags:", //nolint:staticcheck // strings.Title in test is okay } } return nil diff --git a/mapper_test.go b/mapper_test.go index a6ddbe3..947f836 100644 --- a/mapper_test.go +++ b/mapper_test.go @@ -268,9 +268,8 @@ func TestFileContentFlag(t *testing.T) { var cli struct { File kong.FileContentFlag } - f, err := os.CreateTemp("", "") + f, err := os.CreateTemp(t.TempDir(), "") assert.NoError(t, err) - defer os.Remove(f.Name()) fmt.Fprint(f, "hello world") f.Close() _, err = mustNew(t, &cli).Parse([]string{"--file", f.Name()}) @@ -282,9 +281,8 @@ func TestNamedFileContentFlag(t *testing.T) { var cli struct { File kong.NamedFileContentFlag } - f, err := os.CreateTemp("", "") + f, err := os.CreateTemp(t.TempDir(), "") assert.NoError(t, err) - defer os.Remove(f.Name()) fmt.Fprint(f, "hello world") f.Close() _, err = mustNew(t, &cli).Parse([]string{"--file", f.Name()}) diff --git a/resolver.go b/resolver.go index 29be1b9..3e37ca7 100644 --- a/resolver.go +++ b/resolver.go @@ -63,6 +63,6 @@ func JSON(r io.Reader) (Resolver, error) { } func snakeCase(name string) string { - name = strings.Join(strings.Split(strings.Title(name), "-"), "") + name = strings.Join(strings.Split(strings.Title(name), "-"), "") //nolint:staticcheck // Unicode punctuation not an issue return strings.ToLower(name[:1]) + name[1:] } diff --git a/util_test.go b/util_test.go index 5ec0131..78302ef 100644 --- a/util_test.go +++ b/util_test.go @@ -16,9 +16,8 @@ func TestConfigFlag(t *testing.T) { Flag string } - w, err := os.CreateTemp("", "") + w, err := os.CreateTemp(t.TempDir(), "") assert.NoError(t, err) - defer os.Remove(w.Name()) w.WriteString(`{"flag": "hello world"}`) //nolint: errcheck w.Close()