We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The standard library maps package and its golang.org/x/exp/maps variant allowed newcomers to write code in a suboptimal way. Some examples found:
maps
// exp maps, OSPACE(n) complexity for _, k := range maps.Keys(m) { /*...*/ } // standard library maps for k := range maps.Keys(m) { /*...*/ } // idiomatic for k := range m { /*...*/ }
// exp maps, OSPACE(n) complexity for _, v := range maps.Values(m) { /*...*/ } // standard library maps for v := range maps.Values(m) { /*...*/ } // idiomatic for _, v := range m { /*...*/ }
// exp maps, OSPACE(n) compexity, OTIME(n) complexity if slices.Contains(maps.Keys(m), k) { /*...*/ } // idiomatic if _, ok := m[k]; ok { /*...*/ }
in one case, we also saw:
// standard library maps for k, v := range maps.All(m) { /*...*/ } // idiomatic for k, v := range m { /*...*/ }
It would be nice to show warnings for:
The text was updated successfully, but these errors were encountered:
exp maps use, as the standard library has feature parity
We'll wait for the Go team to deprecate the package instead.
maps package use where it's not necessary, like directly in a range loop
I agree that these uses should be simplified and we can probably flag that.
Sorry, something went wrong.
No branches or pull requests
The standard library
maps
package and its golang.org/x/exp/maps variant allowed newcomers to write code in a suboptimal way. Some examples found:in one case, we also saw:
It would be nice to show warnings for:
The text was updated successfully, but these errors were encountered: