Skip to content

fix: use %d format verb for ShellCompDirective in test error message#2432

Closed
amitmishra11 wants to merge 1 commit into
spf13:mainfrom
amitmishra11:fix/shellcompdirective-format-verb
Closed

fix: use %d format verb for ShellCompDirective in test error message#2432
amitmishra11 wants to merge 1 commit into
spf13:mainfrom
amitmishra11:fix/shellcompdirective-format-verb

Conversation

@amitmishra11

Copy link
Copy Markdown

Summary

Go 1.26 tightened go vet to flag %q used with non-string/rune arguments as an error. ShellCompDirective is defined as type ShellCompDirective int, so the format call on line 3730 of completions_test.go now fails the vet check and prevents the test suite from compiling on Go 1.26.

./completions_test.go:3730:37: (*testing.common).Errorf format %q has arg directive of wrong type github.com/spf13/cobra.ShellCompDirective

Changes

  • completions_test.go line 3730: replace %q with %d in the t.Errorf call that formats a ShellCompDirective value

Testing

$ go test ./...
ok  github.com/spf13/cobra      9.4s
ok  github.com/spf13/cobra/doc  0.4s

Fixes #2422

ShellCompDirective is defined as type int. Using the %q format verb
with an integer type was flagged as a vet error in Go 1.26 due to
a stricter check on format/argument type mismatches, causing the
test suite to fail to compile on that version.

Replace %q with %d, which is the correct verb for an integer value.

Fixes spf13#2422
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Amit Mishra seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ccoVeille

Copy link
Copy Markdown
Contributor

@marckhouzam marckhouzam closed this Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test failed with golang 1.26

4 participants