Commit dce8eb65 by gongyang

设置超时时间

parent e06f08d3
Showing with 4 additions and 0 deletions
package main package main
import ( import (
"context"
"flag" "flag"
"fmt" "fmt"
"golang-asynctask/app/dao/scm_data_dao" "golang-asynctask/app/dao/scm_data_dao"
...@@ -54,6 +55,9 @@ func main() { ...@@ -54,6 +55,9 @@ func main() {
//UpdateOldGoodsId() //UpdateOldGoodsId()
//panic(1) //panic(1)
_, cancel := context.WithTimeout(context.Background(), 120*time.Second)
defer cancel() // 确保在函数结束时调用cancel,以释放资源
runtime.GOMAXPROCS(5) runtime.GOMAXPROCS(5)
//获取当天时间 //获取当天时间
var currentDate = time.Now().Format("2006-01-02") var currentDate = time.Now().Format("2006-01-02")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment