There's no need to use maps, you want to follow this pattern: for i := range items { if i==0 || !grouped(i-1, i) { appendToResult } appendToGroup }
Here's the full example: https://play.golang.org/p/1e0rDDmq7b -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.