Skip to content

fix: treat empty string-array values as empty slices#481

Open
Yongcheng123 wants to merge 1 commit into
spf13:masterfrom
Yongcheng123:fix/string-array-empty-value
Open

fix: treat empty string-array values as empty slices#481
Yongcheng123 wants to merge 1 commit into
spf13:masterfrom
Yongcheng123:fix/string-array-empty-value

Conversation

@Yongcheng123
Copy link
Copy Markdown

Summary

  • treat explicit empty StringArray values as an empty slice instead of a single empty-string element
  • make the bound []string agree with GetStringArray() and String() for --flag= and --flag ""
  • add regression coverage for both FlagSet.Parse and CommandLine.Parse

Testing

  • go test ./... -run 'TestEmptySAValue|TestEmptySASeparateValue|TestEmptySASeparateValueCommandLine'
  • go test ./...
  • go vet ./...

Closes #415

@tomasaschan
Copy link
Copy Markdown
Collaborator

Please see #415 (comment)

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.

Passing empty string to StringArrayVar results in array of 1 element

2 participants