Repository navigation
Conversation
|
coilysiren
approved these changes
Oct 6, 2026
| assert.Equal(t, []string{"positional"}, args) | ||
| }) | ||
|
|
||
| t.Run("-vn= in a short option group sets empty string", func(t *testing.T) { |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
What this PR does / why we need it:
#2297 (for #2293) made
--name=set the flag to an empty string instead of reading the next argument as its value. The short option group path inparseFlagswas not changed, so withUseShortOptionHandlingthe same=behaves differently once the flag is the last member of a group:nbeforenafterapp -n= positional"", args[positional]app -vn= positional"positional", args[]"", args[positional]app -vn=flag needs an argument: n""command_parse.go: the last flag of a short option group only reads the next argument when there was no=in the token, which is the same!valFromEqualcheck the single flag path already has.command_test.go: two subtests inTestFlagEqualsEmptyValue, one for-vn= positionaland one for-vn=at the end of the args.Which issue(s) this PR fixes:
None filed. I found this while reading the short option code next to the #2297 change and couldn't find an existing issue or PR about it.
Testing
main(the positional is consumed as the value;flag needs an argument: n) and pass with the change.make generate vet test gfmrunpasses.make generaterewrites a few doc links ingodoc-current.txtwith my local Go 1.24, onmaintoo, so I left that file alone.Release Notes