I've pulled together a very simple go generate-or that makes sorting arbitrary slices easier via order functions, removing the need to implement sort.Interface etc. go get -u github.com/myitcv/sorter/cmd/sortGen
Simply define an order function on the slice type of interest: func orderByName(persons []person, i, j int) sorter.Order { return persons[i].name < persons[j].name } then run go generate and a corresponding sort function will have been generated for you: // gen_person_sorter.go func sortByName(vs []person) { // ... See the example and rules at the following link for more details: https://github.com/myitcv/sorter/tree/master/cmd/sortGen Hopefully some folks will find this useful and a good introduction to go generate. Thoughts, feedback etc much appreciated. (motivated by this ongoing thread <https://github.com/golang/go/issues/16721>) -- 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.