From 7a412e68227024d598671fff8dfb86d5d2ed42ea Mon Sep 17 00:00:00 2001 From: Matt Schwager Date: Thu, 6 Jun 2024 09:29:01 -0400 Subject: [PATCH] Add test for known FP for iterate-over-empty-map --- go/iterate-over-empty-map.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/go/iterate-over-empty-map.go b/go/iterate-over-empty-map.go index 9401dfa..48f67d5 100644 --- a/go/iterate-over-empty-map.go +++ b/go/iterate-over-empty-map.go @@ -12,6 +12,7 @@ func main() { iter1_FP_2() iter1_FP_3() iter1_FP_4() + iter1_FP_5() } func iter1(){ @@ -72,3 +73,18 @@ func iter1_FP_4(){ fmt.Println("map item: ", v) } } + +func iter1_FP_5() { + // https://github.com/semgrep/semgrep/issues/9558 + // todook: iterate-over-empty-map + testMap := map[string]int{ + "foo": 1, + "bar": 2, + } + + keys := make([]string, 0, len(testMap)) + + for k := range testMap { + keys = append(keys, k) + } +}