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 }
版权声明:本文为siaslfslovewp原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。