Skip to content

fix: allow explicit empty numeric slice values - #514

Open
sb123sb123 wants to merge 1 commit into
spf13:masterfrom
sb123sb123:codex/fix-explicit-empty-slices
Open

sb123sb123 wants to merge 1 commit into
spf13:masterfrom
sb123sb123:codex/fix-explicit-empty-slices

Conversation

@sb123sb123

Copy link
Copy Markdown

Fixes #222

Passing --data= to numeric and duration slice flags currently attempts to parse an empty token, so callers cannot distinguish an explicitly requested empty slice from an omitted flag.

This change treats the first explicit empty value as a non-nil empty slice for duration, float32, float64, int, int32, int64, and uint slices. It preserves nil, empty, and populated defaults when the flag is omitted, and keeps repeated non-empty values appendable. Bool, string, IP, and CIDR slice types already accept this syntax.

A matching earlier PR (#512) was withdrawn by its author because the required CLA could not be completed; the issue remains open and this change is independently tested against the current master base.

Tests:

  • go test . -run "Test.*Slice" -count=1 with Go 1.26.7
  • go vet . with Go 1.26.7
  • The added regression failed on the pre-change master base for duration, float32, float64, int, int32, int64, and uint with empty-token parse errors, then passed after the fix.

Limitations: the full repository test suite, GitHub Actions matrix, and lint workflow were not run locally.

AI assistance: OpenAI Codex (GPT-5.6 Luna).

@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.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

Can't pass empty int slices

2 participants