Skip to content

Commit

Permalink
fix: prevent non-nil keys for nil map
Browse files Browse the repository at this point in the history
  • Loading branch information
horockey committed Aug 7, 2024
1 parent bd235d8 commit bf82dab
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2397,6 +2397,10 @@ func TestTimestampFlagApply_MultipleFormats(t *testing.T) {

// TODO: replace with maps.Keys() (go >= ), lo.Keys() if acceptable
getKeys := func(m map[string]time.Duration) []string {
if m == nil {
return nil
}

keys := make([]string, 0, len(m))
for k := range m {
keys = append(keys, k)
Expand Down Expand Up @@ -2464,6 +2468,10 @@ func TestTimestampFlagApply_ShortenedLayouts(t *testing.T) {

// TODO: replace with maps.Keys() (go >= ), lo.Keys() if acceptable
getKeys := func(m map[string]time.Duration) []string {
if m == nil {
return nil
}

keys := make([]string, 0, len(m))
for k := range m {
keys = append(keys, k)
Expand Down

0 comments on commit bf82dab

Please sign in to comment.