feat(Go-StudyExample):

2020/12/31:添加container包使用示例和源码分析

                       2020/12/31:添加validator.v8源码解析和使用示例
This commit is contained in:
Huangzj
2020-12-31 16:48:30 +08:00
parent 6d079549f1
commit 9c93a35685
22 changed files with 5167 additions and 0 deletions
@@ -0,0 +1,36 @@
/*
* @Author : huangzj
* @Time : 2020/12/2 15:39
* @Description
*/
package testContainer
type Person struct {
Name string //名字
Age int //年龄
Money float64 //身价
}
type heapTool []*Person
func (h *heapTool) Less(i, j int) bool {
return (*h)[i].Age < (*h)[j].Age
}
func (h *heapTool) Swap(i, j int) {
(*h)[i], (*h)[j] = (*h)[j], (*h)[i]
}
func (h *heapTool) Len() int {
return len(*h)
}
func (h *heapTool) Pop() (v interface{}) {
*h, v = (*h)[:h.Len()-1], (*h)[h.Len()-1]
return
}
func (h *heapTool) Push(v interface{}) {
*h = append(*h, v.(*Person))
}