| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- package main
- import (
- "fmt"
- "math/rand"
- // "sort"
- "time"
- // "strings"
- )
- func main() {
- // str := "http://192.168.1.1:8080"
- // str2 := "http://192.168.1.1/wecd"
- // str3 := "http://192.168.1.1/"
- // str4 := "http://192.168.1.1/erreg/tth"
- // fmt.Println(strings.Split(str, "/")[2])
- // fmt.Println(strings.Split(str2, "/")[2])
- // fmt.Println(strings.Split(str3, "/")[2])
- // fmt.Println(strings.Split(str4, "/")[2])
- // //fmt.Println(strings.Split(str, "/")[3])
- // fmt.Println(strings.Split(str2, "/")[3])
- // fmt.Println(strings.Split(str3, "/")[3])
- // fmt.Println(strings.Split(str4, "/")[3:])
- // fmt.Println(strings.Join(strings.Split(str4, "/")[3:], "/"))
- // fmt.Println(len(strings.Split(str, "/")))
- // fmt.Println(len(strings.Split(str2, "/")))
- // fmt.Println(len(strings.Split(str3, "/")))
- // fmt.Println(len(strings.Split(str4, "/")))
- // tt := " 22 34 "
- // fmt.Println(len(tt))
- // fmt.Println("dasdasd", len(strings.Split("2324", " ")))
- // fmt.Printf("%s%s", strings.TrimSpace(tt), "ooooo")
- // fmt.Println(len(strings.TrimSpace(tt)))
- // fmt.Println(1160581.8031 - 328704.2531 - 292244.6031)
- //
- fmt.Println(GetRemainSeconds(), SecondsUntilEndOfDay())
- // fmt.Println(SecondsUntilEndOfDay())
- }
- func GetRemainSeconds() time.Duration {
- now := time.Now()
- return time.Date(now.Year(), now.Month(), now.Day()+1, 0, 0, 0, 0, now.Location()).Sub(now)
- }
- func SecondsUntilEndOfDay() time.Duration {
- // 获取当前时间
- now := time.Now()
- // 构造当天的 23:59:59 时间
- endOfDay := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 0, now.Location())
- // 计算当前时间与 23:59:59 的时间差
- duration := endOfDay.Sub(now)
- // 返回剩余的秒数
- return duration
- }
- func SelectNumbers(min, max, count, interval int) []int {
- // 生成满足间隔条件的所有数字
- var candidates []int
- for i := min; i <= max; i += interval {
- candidates = append(candidates, i)
- }
- // 如果可选数量不足,调整 count
- if len(candidates) < count {
- count = len(candidates)
- }
- rand.Seed(time.Now().UnixNano())
- rand.Shuffle(len(candidates), func(i, j int) {
- candidates[i], candidates[j] = candidates[j], candidates[i]
- })
- // 直接取前 count 个数字
- return candidates[:count]
- }
|