panic: time: missing Location in call to Time.In

docker容器发布go项目出现以下问题:

panic: time: missing Location in call to Time.In

COPY --from=build /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai  //注意路径

main.go 

func init() {
   //处理全局时区问题,删了剁手
   sh, _ := time.LoadLocation("Asia/Shanghai")
   time.Local = sh
}

 

定时任务:

task := cron.New()                                               //创建定时任务
task.AddFunc(sysConfig.TaskConfig.ActivityConfig, startActivity) //添加一个定时任务,可以AddFunc 多次.
task.AddFunc(sysConfig.TaskConfig.ActivityConfig, stopActivity)  //添加一个定时任务,可以AddFunc 多次.
task.AddFunc(sysConfig.TaskConfig.ActivityConfig, tasks.PullA8ReceiveBills)
task.AddFunc(sysConfig.TaskConfig.ActivityConfig, tasks.SyncPurchaseApplyState)
task.AddFunc(sysConfig.TaskConfig.ActivityConfig, tasks.SyncReturnApplyState)

task.Start()

 

时间格式化:

var dateStr = time.Now().Format("2006-01-02 15:04:05")

  

结构体:(首字母大写,不然数据库绑定无法取值)

type A8btype struct {
	Usercode      string
	Fullname      string
	TelAndAddress string
	CreateDate    time.Time
}

  




posted @ 2019-07-20 21:55  siaslfs  阅读(1669)  评论(0编辑  收藏  举报