package main import ( "fmt" "runtime" "testing" "time" ) func TestMultiTreeChinese(t *testing.T) { mt := NewMultiTree() words := []string{"芜湖市伍月服装有限公司", "芜湖东安建设工程咨询有限公司", "安徽帮扶教育科技集团有限公司", "芜湖爱菊营销策划有限公司", "安徽省无为县精诚电器有限责任公司", "芜湖通益建筑安装有限责任公司", "芜湖县糖烟酒日杂有限公司", "芜湖文晖商贸经营部", "芜湖市阪新服饰有限公司", "芜湖市尚居装饰设计工程有限公司", "安徽天江建设有限公司"} for _, word := range words { mt.Add(word) } results := mt.Match("芜湖文晖商贸经营部", true) fmt.Println(results) } func TestMonday(t *testing.T) { now := time.Now() // 获取当前时间的星期几(0表示周一,1表示周二,以此类推) weekday := now.Weekday() // 计算从周日到现在的天数(因为一周从周日开始,所以需要减一天) daysSinceSunday := int(weekday) - 1 // 计算周一的时间 monday := now.AddDate(0, 0, -daysSinceSunday) // 将时间格式化为凌晨(00:00:00) mondayAtMidnight := time.Date(monday.Year(), monday.Month(), monday.Day(), 0, 0, 0, 0, monday.Location()) fmt.Println("aaa", mondayAtMidnight.Unix()) fmt.Println("当前时间:", now.Format("2006-01-02 15:04:05 MST")) fmt.Println("本周周一凌晨时间:", mondayAtMidnight.Format("2006-01-02 15:04:05 MST")) } func TestNewMultiTree(t *testing.T) { for i := 0; i < 1000000; i++ { _ = make([]byte, 1024) // Allocate 1 Kb } TraceMemStats() // Explicitly trigger a garbage collection runtime.GC() TraceMemStats() // Sleep for a while to observe the changes in memory stats time.Sleep(time.Second * 2) TraceMemStats() }