Skip to content

fix: allow hex input in UintSlice#484

Merged
tomasaschan merged 1 commit into
spf13:masterfrom
happysnaker:fix-uint-slice-hex-input
Jul 2, 2026
Merged

fix: allow hex input in UintSlice#484
tomasaschan merged 1 commit into
spf13:masterfrom
happysnaker:fix-uint-slice-hex-input

Conversation

@happysnaker

Copy link
Copy Markdown

Summary

  • make UintSlice parse values with base autodetection instead of decimal-only parsing
  • keep UintSlice aligned with other integer slice flags that already accept 0x input
  • add regression coverage for hexadecimal UintSlice values

Problem

Issue #229 reports that UintSliceVar rejects inputs like 0x86 even though other integer slice flags accept Go-style base prefixes. Today UintSlice uses strconv.ParseUint(..., 10, 0) in parsing, replacement, and getter conversion paths, so hexadecimal values fail unexpectedly.

Fix

Switch the UintSlice parsing paths to strconv.ParseUint(..., 0, 0) so base prefixes are handled consistently across parse, replace, and GetUintSlice().

Closes #229

@happysnaker

Copy link
Copy Markdown
Author

Maintainer context: this is intended as a minimal consistency fix for UintSlice, not a new flag syntax. strconv.ParseUint(..., 0, 0) already matches Go's normal integer literal behavior (123, 077, 0x86), so this just brings the slice variant in line with that expectation and with the linked report in #229.

@tomasaschan tomasaschan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look OK to me, but there are some stray things around IP address parsing that have snuck into the diff. Needs a rebase, maybe?

@happysnaker happysnaker force-pushed the fix-uint-slice-hex-input branch from fa0c373 to 298bcdf Compare July 2, 2026 06:37
@happysnaker

Copy link
Copy Markdown
Author

Rebased and force-pushed on July 2, 2026 to drop the unrelated ip.go / ip_test.go hunks that had accidentally slipped into the branch. The PR is back to the minimal UintSlice-only diff now (298bcdf). CI should rerun from the cleaned branch.

@tomasaschan

Copy link
Copy Markdown
Collaborator

Thanks for these contributions!

@tomasaschan tomasaschan merged commit 95a0aa3 into spf13:master Jul 2, 2026
8 checks passed
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.

invalid argument "0x86" for "-u, --data" flag: strconv.ParseUint: parsing "0x86": invalid syntax

2 participants