本文介绍了致电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时缺少位置
发布评论