Comments (3)
Hi, thanks for reaching out. At first glance, it looks like it might be possible to add some sort of check for these types of errors. I'll try to take a closer look when I get a moment.
from prealloc.
Thank you very much. I believe this mistake is quite common, especially due to the confusing pre-allocation of arrays vs maps in Golang. In arrays, the extra ,0
is needed to specify capacity, but not in maps.
from prealloc.
I recently found out that there is a linter for that: https://github.com/ashanbrown/makezero
That also has "Consider whether this should be part of prealloc itself." in TODO.
from prealloc.
Related Issues (12)
- Use copy() instead of append() for large arrays HOT 6
- Prealloc confused by variable redeclaration HOT 1
- prealloc confused by ranging over a channel HOT 3
- line of sight loops trick prealloc HOT 1
- is preallocating array with 0 length still get benefit on performance ? HOT 2
- Support for custom slice types or aliases HOT 2
- Map preallocation HOT 3
- Variadic parameters might not need preallocation HOT 2
- Duplicate output lines for repeat append calls in a loop HOT 3
- Add unit tests
- Set exit status when suggestions are found HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prealloc.