致电Time.In时缺少位置

编程入门 行业动态 更新时间:2024-10-08 05:32:26
本文介绍了致电Time.In时缺少位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我使用beego / orm操作Postgresql数据库时,会出现诸如在调用Time.In时缺少位置之类的错误。

When I ues beego/orm to operate postgresql database,there is an error like this "missing Location in call to Time.In".

代码示例

type dataTest struct { Id int `pk:"auto"` Data time.Time `orm:"auto_now;type(timestamp);null"` } local, _ := time.LoadLocation("UTC") test_time, err := time.ParseInLocation("2006-01-02 15:04:05", "1111-01-25 14:27:07", local) orm.DefaultTimeLoc = time.UTC o,err := orm.NewOrmWithDB("postgres","default",db) temp := new(dataTest) temp.Id = 1 temp.Data = test_time o.Update(temp)

推荐答案

对于docker(构建多阶段)

For docker (build multi stage)

在构建后安装 tzdata

RUN apk --no-cache add tzdata

可用时区列表,请参见: golang/src/time/zoneinfo_abbrs_windows.go

List of time zones available, see: golang/src/time/zoneinfo_abbrs_windows.go

loc, _ := time.LoadLocation("America/Bogota") now := time.Now().In(loc)

更多推荐

致电Time.In时缺少位置

本文发布于:2023-11-12 02:11:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580206.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:位置   Time

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!