package mhayaSlice import ( "fmt" mhayaString "github.com/mhaya/extend/string" mhayaTime "github.com/mhaya/extend/time" "slices" "testing" "time" ) //func TestUnique(t *testing.T) { // list := Unique[string]("1", "2", "3", "1") // fmt.Println(list) //} var currentTime = int64(1727683200) func TestUniques(t *testing.T) { //s1 := []string{"1", "2", "3"} //s2 := []string{"1", "2", "3"} // //list := Uniques[string](s1, s2) //fmt.Println(list) // 上次恢复时间 var roolDay = int64(1727593200) for i := 0; i < 10; i++ { RefreshRoll(&roolDay) } } func RefreshRoll(roolDay *int64) bool { arr := []string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24"} slice := make([]int, 0) for _, s := range arr { hour, _ := mhayaString.ToInt(s) slice = append(slice, hour) } // 小时数,24小时制 //curHour := time.Now().Hour() curHour := 16 rollHour := time.Unix(*roolDay, 0).Hour() isToday := mhayaTime.CreateFromTimestamp(*roolDay).IsToday() if isToday { slice = slices.DeleteFunc(slice, func(x int) bool { return x <= rollHour }) } fmt.Println("slice:", slice) if slices.Contains(slice, curHour) { *roolDay = currentTime fmt.Println(" execute ==> num := p.Item[ItemRoll].AddSameTwo()") return true } return false }