Open delve opened 4 months ago
You're right that in this particular instance, the suggestion isn't useful. We probably could try to handle it, but it should be noted that at first glance, at least for this minimal example, the use of a loop seems odd.
Yes, the example above is contrived for brevity. In my actual code I receive a map[string]struct from a 3rd party module which will have some or all of a set of options. The set of options returned is based on user input, unpredictable, and each key must be processed uniquely. So I use the above procedure to deal with it.
If you happen to know a better way to handle that I'd love some hints. :)
staticcheck 2023.1.6 (v0.4.6) reports
on the code
I'm new to Go so perhaps I'm doing it wrong, but it seems that the
switch key
will only allow the regex to run once, making the lint finding invalid. OTOH maybe this is too small/awkward a case to warrant handling? Since it depends on several factors (ranging over map keys and switching on the key)versions