2024年8月28日

go 结构体列表比较是否相等

摘要: 使用reflect的DeepEqual方法 场景1:结构体列表按顺序匹配(直接比较) package main import ( "fmt" "reflect" ) type Student struct { Age int Score int } func main() { s1 := []Stu 阅读全文

posted @ 2024-08-28 21:15 王景迁 阅读(1) 评论(0) 推荐(0) 编辑

go 结构体切片自定义排序

摘要: 常见类型的默认排序实现 go sort包默认支持int(sort.Ints(x []int))、float64s(sort.Float64s(x []float64))、string(sort.Strings(x []string))从小到大排序,反序使用类似于sort.Sort(sort.Reve 阅读全文

posted @ 2024-08-28 20:58 王景迁 阅读(10) 评论(0) 推荐(0) 编辑

导航