Skip to content

Conversation

@hujun-open
Copy link

No description provided.

@CLAassistant
Copy link

CLAassistant commented Dec 27, 2024

CLA assistant check
All committers have signed the CLA.

@hujun-open
Copy link
Author

Could this PR be looked? it has been a while since opened...

text_test.go Outdated
Comment on lines 36 to 51
if err != nil && tc.success == true {
t.Errorf("expected success, got %q", err)
continue
} else if err == nil && tc.success == false {
t.Errorf("expected failure, but succeeded")
continue
} else if tc.success {
parsedT := new(time.Time)
err := f.GetText("time", parsedT)
if err != nil {
t.Errorf("Got error trying to fetch the time flag: %v", err)
}
if !parsedT.Equal(tc.expected) {
t.Errorf("expected %q, got %q", tc.expected, parsedT)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm surprised the linter doesn't complain about the unnecessary nesting here. Here's a slight simplification (that also makes it clearer why we don't handle the !tc.success case on its own):

Suggested change
if err != nil && tc.success == true {
t.Errorf("expected success, got %q", err)
continue
} else if err == nil && tc.success == false {
t.Errorf("expected failure, but succeeded")
continue
} else if tc.success {
parsedT := new(time.Time)
err := f.GetText("time", parsedT)
if err != nil {
t.Errorf("Got error trying to fetch the time flag: %v", err)
}
if !parsedT.Equal(tc.expected) {
t.Errorf("expected %q, got %q", tc.expected, parsedT)
}
}
if err != nil {
// parsing failed...
if tc.success {
// ...and we did not expect it to
t.Errorf("Expected parsing to succeed, but got %v", err)
}
continue
}
if err == nil && !tc.success {
t.Errorf("Expected parsing failure, but parsing succeeded")
continue
}
parsedT := new(time.Time)
err := f.GetText("time", parsedT)
if err != nil {
t.Errorf("Got error trying to fetch the time flag: %v", err)
}
if !parsedT.Equal(tc.expected) {
t.Errorf("Expected %q, got %q", tc.expected, parsedT)
}

text_test.go Outdated
expected time.Time
}{
{"2003-01-02T15:04:05Z", true, time.Date(2003, 1, 2, 15, 04, 05, 0, time.UTC)},
{"2003-01-02 15:05:01", false, time.Date(2002, 1, 2, 15, 05, 05, 07, time.UTC)},
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test case is confusing me: it's providing a string which I assume will fail parsing (?) but then it also provides a time.Date instance that doesn't match. That makes it hard to see, at a glance, why we expect this test to fail.

Can we maybe provide an empty time.Date instance to signal that we don't actually expect to look at it in the test?

Suggested change
{"2003-01-02 15:05:01", false, time.Date(2002, 1, 2, 15, 05, 05, 07, time.UTC)},
{"2003-01-02 15:05:01", false, time.Time{}}, // invalid date string

- return is missing in one error path of GetText(), fixed
@hujun-open
Copy link
Author

Ok, I have updated based on your comments

btw: the nesting if was result of copy&paste from existing _test file, similar nesting if exists in bytes_test.go, count_test.go, ip_test.go and ipnet_test.go

Copy link
Collaborator

@tomasaschan tomasaschan left a comment

Choose a reason for hiding this comment

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

Nice, thank you for your contribution!

@tomasaschan tomasaschan merged commit 196624c into spf13:master May 15, 2025
5 checks passed
@LeGEC
Copy link

LeGEC commented May 30, 2025

This PR also fixes #355

project-mirrors-bot-tu bot pushed a commit to project-mirrors/forgejo-runner-as-gitea-act-runner-fork that referenced this pull request Aug 2, 2025
This PR contains the following updates:

| Package | Change | Age | Confidence |
|---|---|---|---|
| [github.com/spf13/pflag](https://github.com/spf13/pflag) | `v1.0.6` -> `v1.0.7` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fspf13%2fpflag/v1.0.7?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fspf13%2fpflag/v1.0.6/v1.0.7?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>spf13/pflag (github.com/spf13/pflag)</summary>

### [`v1.0.7`](https://github.com/spf13/pflag/releases/tag/v1.0.7)

[Compare Source](spf13/pflag@v1.0.6...v1.0.7)

#### What's Changed

- Fix defaultIsZeroValue check for generic Value types by [@&#8203;MidnightRocket](https://github.com/MidnightRocket) in spf13/pflag#422
- feat: Use structs for errors returned by pflag. by [@&#8203;eth-p](https://github.com/eth-p) in spf13/pflag#425
- Fix typos by [@&#8203;co63oc](https://github.com/co63oc) in spf13/pflag#428
- fix [#&#8203;423](spf13/pflag#423) : Add helper function and some documentation to parse shorthand go test flags. by [@&#8203;valdar](https://github.com/valdar) in spf13/pflag#424
- add support equivalent to golang flag.TextVar(), also fixes the test failure as described in [#&#8203;368](spf13/pflag#368) by [@&#8203;hujun-open](https://github.com/hujun-open) in spf13/pflag#418
- add support for Func() and BoolFunc() [#&#8203;426](spf13/pflag#426) by [@&#8203;LeGEC](https://github.com/LeGEC) in spf13/pflag#429
- fix: correct argument length check in FlagSet.Parse by [@&#8203;ShawnJeffersonWang](https://github.com/ShawnJeffersonWang) in spf13/pflag#409
- fix usage message for func flags, fix arguments order by [@&#8203;LeGEC](https://github.com/LeGEC) in spf13/pflag#431
- Add support for time.Time flags by [@&#8203;max-frank](https://github.com/max-frank) in spf13/pflag#348

#### New Contributors

- [@&#8203;MidnightRocket](https://github.com/MidnightRocket) made their first contribution in spf13/pflag#422
- [@&#8203;eth-p](https://github.com/eth-p) made their first contribution in spf13/pflag#425
- [@&#8203;co63oc](https://github.com/co63oc) made their first contribution in spf13/pflag#428
- [@&#8203;valdar](https://github.com/valdar) made their first contribution in spf13/pflag#424
- [@&#8203;hujun-open](https://github.com/hujun-open) made their first contribution in spf13/pflag#418
- [@&#8203;LeGEC](https://github.com/LeGEC) made their first contribution in spf13/pflag#429
- [@&#8203;ShawnJeffersonWang](https://github.com/ShawnJeffersonWang) made their first contribution in spf13/pflag#409
- [@&#8203;max-frank](https://github.com/max-frank) made their first contribution in spf13/pflag#348

**Full Changelog**: spf13/pflag@v1.0.6...v1.0.7

</details>

---

### Configuration

📅 **Schedule**: Branch creation - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC), Automerge - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC).

🚦 **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:eyJjcmVhdGVkSW5WZXIiOiI0MS40My41IiwidXBkYXRlZEluVmVyIjoiNDEuNDMuNSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/794
Reviewed-by: earl-warren <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
Co-committed-by: Renovate Bot <[email protected]>
algitbot pushed a commit to alpinelinux/build-server-status that referenced this pull request Nov 9, 2025
This MR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/spf13/pflag](https://github.com/spf13/pflag) | require | patch | `v1.0.6` -> `v1.0.10` |

---

### Release Notes

<details>
<summary>spf13/pflag (github.com/spf13/pflag)</summary>

### [`v1.0.10`](https://github.com/spf13/pflag/releases/tag/v1.0.10)

[Compare Source](spf13/pflag@v1.0.9...v1.0.10)

#### What's Changed

- fix deprecation comment for (FlagSet.)ParseErrorsWhitelist by [@&#8203;thaJeztah](https://github.com/thaJeztah) in [#&#8203;447](spf13/pflag#447)
- remove uses of errors.Is, which requires go1.13, move go1.16/go1.21 tests to separate file by [@&#8203;thaJeztah](https://github.com/thaJeztah) in [#&#8203;448](spf13/pflag#448)

#### New Contributors

- [@&#8203;thaJeztah](https://github.com/thaJeztah) made their first contribution in [#&#8203;447](spf13/pflag#447)

**Full Changelog**: <spf13/pflag@v1.0.9...v1.0.10>

### [`v1.0.9`](https://github.com/spf13/pflag/releases/tag/v1.0.9)

[Compare Source](spf13/pflag@v1.0.8...v1.0.9)

#### What's Changed

- fix: Restore ParseErrorsWhitelist name for now by [@&#8203;tomasaschan](https://github.com/tomasaschan) in [#&#8203;446](spf13/pflag#446)

**Full Changelog**: <spf13/pflag@v1.0.8...v1.0.9>

### [`v1.0.8`](https://github.com/spf13/pflag/releases/tag/v1.0.8)

[Compare Source](spf13/pflag@v1.0.7...v1.0.8)

#### ⚠️ Breaking Change

This version, while only a patch bump, includes a (very minor) breaking change: the `flag.ParseErrorsWhitelist` struct and corresponding `FlagSet.parseErrorsWhitelist` field have been renamed to `ParseErrorsAllowlist`.

This should result in compilation errors in any code that uses these fields, which can be fixed by adjusting the names at call sites. There is no change in semantics or behavior of the struct or field referred to by these names. If your code compiles without errors after bumping to/past v1.0.8, you are not affected by this change.

The breaking change was reverted in v1.0.9, by means of re-introducing the old names with deprecation warnings. The plan is still to remove them in a future release, so if your code does depend on the old names, please change them to use the new names at your earliest convenience.

#### What's Changed

- Remove Redundant "Unknown-Flag" Error by [@&#8203;vaguecoder](https://github.com/vaguecoder) in [#&#8203;364](spf13/pflag#364)
- Switching from whitelist to Allowlist terminology by [@&#8203;dubrie](https://github.com/dubrie) in [#&#8203;261](spf13/pflag#261)
- Omit zero time.Time default from usage line by [@&#8203;mologie](https://github.com/mologie) in [#&#8203;438](spf13/pflag#438)
- implement CopyToGoFlagSet by [@&#8203;pohly](https://github.com/pohly) in [#&#8203;330](spf13/pflag#330)
- flag: Emulate stdlib behavior and do not print ErrHelp by [@&#8203;tmc](https://github.com/tmc) in [#&#8203;407](spf13/pflag#407)
- Print Default Values of String-to-String in Sorted Order by [@&#8203;vaguecoder](https://github.com/vaguecoder) in [#&#8203;365](spf13/pflag#365)
- fix: Don't print ErrHelp in ParseAll by [@&#8203;tomasaschan](https://github.com/tomasaschan) in [#&#8203;443](spf13/pflag#443)
- Reset args on re-parse even if empty by [@&#8203;tomasaschan](https://github.com/tomasaschan) in [#&#8203;444](spf13/pflag#444)

#### New Contributors

- [@&#8203;vaguecoder](https://github.com/vaguecoder) made their first contribution in [#&#8203;364](spf13/pflag#364)
- [@&#8203;dubrie](https://github.com/dubrie) made their first contribution in [#&#8203;261](spf13/pflag#261)
- [@&#8203;mologie](https://github.com/mologie) made their first contribution in [#&#8203;438](spf13/pflag#438)
- [@&#8203;pohly](https://github.com/pohly) made their first contribution in [#&#8203;330](spf13/pflag#330)
- [@&#8203;tmc](https://github.com/tmc) made their first contribution in [#&#8203;407](spf13/pflag#407)
- [@&#8203;tomasaschan](https://github.com/tomasaschan) made their first contribution in [#&#8203;443](spf13/pflag#443)

**Full Changelog**: <spf13/pflag@v1.0.7...v1.0.8>

### [`v1.0.7`](https://github.com/spf13/pflag/releases/tag/v1.0.7)

[Compare Source](spf13/pflag@v1.0.6...v1.0.7)

#### What's Changed

- Fix defaultIsZeroValue check for generic Value types by [@&#8203;MidnightRocket](https://github.com/MidnightRocket) in [#&#8203;422](spf13/pflag#422)
- feat: Use structs for errors returned by pflag. by [@&#8203;eth-p](https://github.com/eth-p) in [#&#8203;425](spf13/pflag#425)
- Fix typos by [@&#8203;co63oc](https://github.com/co63oc) in [#&#8203;428](spf13/pflag#428)
- fix [#&#8203;423](spf13/pflag#423) : Add helper function and some documentation to parse shorthand go test flags. by [@&#8203;valdar](https://github.com/valdar) in [#&#8203;424](spf13/pflag#424)
- add support equivalent to golang flag.TextVar(), also fixes the test failure as described in [#&#8203;368](spf13/pflag#368) by [@&#8203;hujun-open](https://github.com/hujun-open) in [#&#8203;418](spf13/pflag#418)
- add support for Func() and BoolFunc() [#&#8203;426](spf13/pflag#426) by [@&#8203;LeGEC](https://github.com/LeGEC) in [#&#8203;429](spf13/pflag#429)
- fix: correct argument length check in FlagSet.Parse by [@&#8203;ShawnJeffersonWang](https://github.com/ShawnJeffersonWang) in [#&#8203;409](spf13/pflag#409)
- fix usage message for func flags, fix arguments order by [@&#8203;LeGEC](https://github.com/LeGEC) in [#&#8203;431](spf13/pflag#431)
- Add support for time.Time flags by [@&#8203;max-frank](https://github.com/max-frank) in [#&#8203;348](spf13/pflag#348)

#### New Contributors

- [@&#8203;MidnightRocket](https://github.com/MidnightRocket) made their first contribution in [#&#8203;422](spf13/pflag#422)
- [@&#8203;eth-p](https://github.com/eth-p) made their first contribution in [#&#8203;425](spf13/pflag#425)
- [@&#8203;co63oc](https://github.com/co63oc) made their first contribution in [#&#8203;428](spf13/pflag#428)
- [@&#8203;valdar](https://github.com/valdar) made their first contribution in [#&#8203;424](spf13/pflag#424)
- [@&#8203;hujun-open](https://github.com/hujun-open) made their first contribution in [#&#8203;418](spf13/pflag#418)
- [@&#8203;LeGEC](https://github.com/LeGEC) made their first contribution in [#&#8203;429](spf13/pflag#429)
- [@&#8203;ShawnJeffersonWang](https://github.com/ShawnJeffersonWang) made their first contribution in [#&#8203;409](spf13/pflag#409)
- [@&#8203;max-frank](https://github.com/max-frank) made their first contribution in [#&#8203;348](spf13/pflag#348)

**Full Changelog**: <spf13/pflag@v1.0.6...v1.0.7>

</details>

---

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

---

&nbsp;
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC4zNy4xIiwidXBkYXRlZEluVmVyIjoiNDEuMTczLjEiLCJ0YXJnZXRCcmFuY2giOiJtYXN0ZXIiLCJsYWJlbHMiOltdfQ==-->

See merge request alpine/infra/build-server-status!21
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.

4 participants