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

Posted 世界之大,程序一家

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
}

  



以上是关于panic: time: missing Location in call to Time.In的主要内容,如果未能解决你的问题,请参考以下文章

PANIC: Missing emulator engine program for ‘x86’ CPU.

2022-10-16:以下go语言代码输出什么?A:timed out;B:panic;C:没有任何输出。 package main import ( “context“ “fmt“

To Miss Our Children Time(dp)

poj 4001 To Miss Our Children Time

quartz问题记录-missed their scheduled fire-time

[音乐] 《犬夜叉》主题曲 Misses beyond time - 穿越时空的思念