On Wed, Mar 8, 2017 at 10:01 AM, Val <delepl...@gmail.com> wrote: > Sorry for not elaborating in the first place (I was trying to make the > point very concise). >
Thank you for detailing further! :-) > The bug in my code is that the two arguments I pass to sort.Slice are > inconsistent : the portion to be sorted is a reslicing from itinerary, > while the "less" closure indexes items of the whole itinerary. > > I brought up the "go vet" idea because I feel that whenever someone will > do some reslicing directly in the first argument, > - either the result will be "broken" like mine, > - or the code in the less function will have to refer to the same > (unnamed) resliced portion, which is imo convoluted : fix 1 > <https://play.golang.org/p/v0V8BQuJ_m> or fix 2 > <https://play.golang.org/p/z_52IQAhY4> . > > The most readable alternative I can think of while still using sort.Slice > is to reslice in a new variable prior to sorting : fix 3 > <https://play.golang.org/p/ZgHyGOLiQO> . > Personally, I would favor fix 3 in this context. Cheers, David -- 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.