Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undersocre support for numbers (set default base for strconv.Parse* to 0) #404

Merged
merged 1 commit into from
Jun 15, 2024

Conversation

GRbit
Copy link
Contributor

@GRbit GRbit commented Apr 16, 2024

Hello, dear @jessevdk! Thank you very much for the library you've built, I'm using it a lot and I enjoy it.

I want to suggest a little improvement for numbers parsing.

Default values in annotations are sometimes quite big, and it would be great to support settings them with underscores like this:

MaxRetries int `long:"max-retries" default:"3_000"`

Default library has support for underscores, but it's a bit vague, you need to set the base to 0. That'll also lead to auto-detecting of the base, which is also nice.

An alternative option is to use strings.ReplaceAll(s, "_", "") which will work, but I prefer to rely on the standard library.

Looking forward to knowing what you think, feel free to request any changes or to make changes yourself.

@GRbit GRbit changed the title Undersocre support for numbers (set default base for strconv.Parse to 0) Undersocre support for numbers (set default base for strconv.Parse* to 0) Apr 16, 2024
@jessevdk jessevdk merged commit 70df99d into jessevdk:master Jun 15, 2024
nabeken referenced this pull request in nabeken/psadm Jun 17, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/jessevdk/go-flags](https://github.com/jessevdk/go-flags)
| require | minor | `v1.5.0` -> `v1.6.1` |

---

### Release Notes

<details>
<summary>jessevdk/go-flags (github.com/jessevdk/go-flags)</summary>

###
[`v1.6.1`](https://github.com/jessevdk/go-flags/releases/tag/v1.6.1)

[Compare
Source](https://github.com/jessevdk/go-flags/compare/v1.6.0...v1.6.1)

**Full Changelog**:
jessevdk/go-flags@v1.6.0...v1.6.1

###
[`v1.6.0`](https://github.com/jessevdk/go-flags/releases/tag/v1.6.0)

[Compare
Source](https://github.com/jessevdk/go-flags/compare/v1.5.0...v1.6.0)

#### What's Changed

- ini: fix IniParser.write() for zero values by
[@&#8203;sean-](https://github.com/sean-) in
[https://github.com/jessevdk/go-flags/pull/332](https://github.com/jessevdk/go-flags/pull/332)
- fix a panic when generating help while the subcommand and all option
groups are hidden by [@&#8203;bboozzoo](https://github.com/bboozzoo)
in
[https://github.com/jessevdk/go-flags/pull/354](https://github.com/jessevdk/go-flags/pull/354)
- Help for positional args without allcmd.ArgsRequired dependent from
arg.Required by [@&#8203;sv99](https://github.com/sv99) in
[https://github.com/jessevdk/go-flags/pull/342](https://github.com/jessevdk/go-flags/pull/342)
- Bump golang.org/x/sys from 0.0.0-20210320140829-1e4c9ba3b0c4 to 0.1.0
by [@&#8203;dependabot](https://github.com/dependabot) in
[https://github.com/jessevdk/go-flags/pull/396](https://github.com/jessevdk/go-flags/pull/396)
- Option to allow passing value to bool flag by
[@&#8203;alexcb](https://github.com/alexcb) in
[https://github.com/jessevdk/go-flags/pull/367](https://github.com/jessevdk/go-flags/pull/367)
- Add support for SOURCE_DATE_EPOCH for TestMan by
[@&#8203;anthonyfok](https://github.com/anthonyfok) in
[https://github.com/jessevdk/go-flags/pull/376](https://github.com/jessevdk/go-flags/pull/376)
- Update to run go-flags on AIX by
[@&#8203;llrocha](https://github.com/llrocha) in
[https://github.com/jessevdk/go-flags/pull/390](https://github.com/jessevdk/go-flags/pull/390)
- Add option for key value delimiter by
[@&#8203;anaprimawaty](https://github.com/anaprimawaty) in
[https://github.com/jessevdk/go-flags/pull/392](https://github.com/jessevdk/go-flags/pull/392)
- Undersocre support for numbers (set default base for strconv.Parse\*
to 0) by [@&#8203;GRbit](https://github.com/GRbit) in
[https://github.com/jessevdk/go-flags/pull/404](https://github.com/jessevdk/go-flags/pull/404)
- docs: add ENV variable usage example by
[@&#8203;cemremengu](https://github.com/cemremengu) in
[https://github.com/jessevdk/go-flags/pull/371](https://github.com/jessevdk/go-flags/pull/371)
- Support per-command PassAfterNonOption by
[@&#8203;woky](https://github.com/woky) in
[https://github.com/jessevdk/go-flags/pull/393](https://github.com/jessevdk/go-flags/pull/393)
- Upgrade by [@&#8203;jessevdk](https://github.com/jessevdk) in
[https://github.com/jessevdk/go-flags/pull/406](https://github.com/jessevdk/go-flags/pull/406)

#### New Contributors

- [@&#8203;sean-](https://github.com/sean-) made their first
contribution in
[https://github.com/jessevdk/go-flags/pull/332](https://github.com/jessevdk/go-flags/pull/332)
- [@&#8203;sv99](https://github.com/sv99) made their first
contribution in
[https://github.com/jessevdk/go-flags/pull/342](https://github.com/jessevdk/go-flags/pull/342)
- [@&#8203;dependabot](https://github.com/dependabot) made their first
contribution in
[https://github.com/jessevdk/go-flags/pull/396](https://github.com/jessevdk/go-flags/pull/396)
- [@&#8203;alexcb](https://github.com/alexcb) made their first
contribution in
[https://github.com/jessevdk/go-flags/pull/367](https://github.com/jessevdk/go-flags/pull/367)
- [@&#8203;anthonyfok](https://github.com/anthonyfok) made their first
contribution in
[https://github.com/jessevdk/go-flags/pull/376](https://github.com/jessevdk/go-flags/pull/376)
- [@&#8203;llrocha](https://github.com/llrocha) made their first
contribution in
[https://github.com/jessevdk/go-flags/pull/390](https://github.com/jessevdk/go-flags/pull/390)
- [@&#8203;anaprimawaty](https://github.com/anaprimawaty) made their
first contribution in
[https://github.com/jessevdk/go-flags/pull/392](https://github.com/jessevdk/go-flags/pull/392)
- [@&#8203;GRbit](https://github.com/GRbit) made their first
contribution in
[https://github.com/jessevdk/go-flags/pull/404](https://github.com/jessevdk/go-flags/pull/404)
- [@&#8203;cemremengu](https://github.com/cemremengu) made their first
contribution in
[https://github.com/jessevdk/go-flags/pull/371](https://github.com/jessevdk/go-flags/pull/371)
- [@&#8203;woky](https://github.com/woky) made their first
contribution in
[https://github.com/jessevdk/go-flags/pull/393](https://github.com/jessevdk/go-flags/pull/393)

**Full Changelog**:
jessevdk/go-flags@v1.5.0...v1.6.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://github.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MDIuMCIsInVwZGF0ZWRJblZlciI6IjM3LjQwMi4wIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=-->
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.

2 participants