3 ms·
IMO The right way is to have a slice filled with pointers rather than bare structs: https://gist.github.com/2975397 https://gist.github.com/2975397 Btw code th
by densh 14y ago
IMO The right way is to have a slice filled with pointers rather than bare structs: https://gist.github.com/2975397 https://gist.github.com/2975397
Btw code that uses range will always be faster than alternative with for loop and indexing (obj[i]) as range-based code can be optimized by Go compiler not to perform any bound checks.
- jbert 14y agoYes, that works nicely, thanks. But sometimes (rarely) you do want a contiguous bunch of objects, rather than have the indirection. I think ideally, it would work (as an alias) but if not, I think it should error. Or maybe this is a FAQ, with a good rationale, which I just haven't got to yet.
- drivebyacct2 14y agoI've been burnt by it as well, I didn't read the spec closely enough apparently. I would love to see it called out in an example.