diff options
| author | Tomas Aschan <[email protected]> | 2025-06-01 11:27:42 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-01 11:27:42 +0200 |
| commit | 8a6c85f2ae488081f953744f9edc414bac10ee45 (patch) | |
| tree | 67d437afa7187f8a88e5bce056f48dc9d0eff667 | |
| parent | bca0664b6991016400b98ac29aae5a73f926bd71 (diff) | |
| parent | f9b6619ed0e0d771f7812fea23cd8b514faf2b2d (diff) | |
Merge pull request #409 from ShawnJeffersonWang/master
fix: correct argument length check in FlagSet.Parse
| -rw-r--r-- | flag.go | 2 | ||||
| -rw-r--r-- | flag_test.go | 6 |
2 files changed, 7 insertions, 1 deletions
@@ -1156,7 +1156,7 @@ func (f *FlagSet) Parse(arguments []string) error { } f.parsed = true - if len(arguments) < 0 { + if len(arguments) == 0 { return nil } diff --git a/flag_test.go b/flag_test.go index aa2f434..ead0518 100644 --- a/flag_test.go +++ b/flag_test.go @@ -100,6 +100,12 @@ func TestEverything(t *testing.T) { } } +func TestNoArgument(t *testing.T) { + if GetCommandLine().Parse([]string{}) != nil { + t.Error("parse failed for empty argument list") + } +} + func TestUsage(t *testing.T) { called := false ResetForTesting(func() { called = true }) |
