New answers tagged


This answer is presuming your Filter and Map should take a slice given the first argument's name. There are other types that reflect's Len() works on which I'm ignoring for this answer. If you want to accept other types, I would suggest changing the name of the first argument to the functions to not be ‘slice’. Use gofmt (or derivative e.g. goimports) to ...


for {} (for loop without condition) loops forever until break. Put the contents of the function in a for {}. Remove the label and replace goto reception with continue. This will cause the current iteration of the loop to end and execution will continue with another iteration, starting from the top of the block. Use break at the end to exit the for loop


I guess I might as well then. To prefix that with: It looks fine as is, there's a few details that could be improved, although those also depend on your team and style guide. Also read it in the context of a bigger project, not everything always applies, especially if it's one-off code, etc. I'm gonna assume (since the formatting is a bit off) that you're ...


From a mathematics and science genius: "If I have seen further it is by standing on the shoulders of Giants." Isaac Newton Wikipedia: Standing on the shoulders of giants For Go giants, you might start with Rob Pike. GitHub - robpike/filter: Simple apply/filter/reduce package. I wanted to see how hard it was to implement this sort of thing in Go, ...

Top 50 recent answers are included