Go1.8发布了,这里先简单学习一下Go1.8的几个新特性。 新的切片排序Api 在以前要对切片排序要实现sort.Interface接口: 1package main 2 3import ( 4 "fmt" 5 "sort" 6) 7 8type Person struct { 9 Name string 10 Age int 11} 12 13func (p Person) String() string { 14 return fmt.Sprintf("%s: %d", p.Name, p.Age) 15} 16 17// ByAge implements sort.Interface for []Person based on 18// the Age field. 19type ByAge []Person……
阅读全文