package main import( "time" "fmt" "net/url" "net/http" ) func sendPost1(){ data:=make(url.Values) data["name"]=[]string{"rnben"} res,err:=http.PostForm("http://127.0.0.1/tpost",data) if err != nil{ fmt.Println(err.Error()) return } deferres.Body.Close() fmt.Println("post send success") } func main(){ for{ now:=time.Now() //计算下一个零点 next:=now.Add(time.Hour*24) next=time.Date(next.Year(),next.Month(),next.Day(),10,40,0,0,next.Location()) fmt.Println("The next event will happen at",next) t:=time.NewTimer(next.Sub(now)) <-t.C fmt.Printf("结算完成:%v",time.Now()) //以下为定时执行的操作 sendPost1() }//for }//Timing
go每日定时提交post
阅读:1539 输入:2023-02-09 22:49:42
- 上一篇:采集案例
- 下一篇:Golang模板应用