相关疑难解决方法(0)

调用 Time.In 时缺少位置

当我使用beego/orm操作postgresql数据库时,出现这样的错误“调用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)
Run Code Online (Sandbox Code Playgroud)

go beego

2
推荐指数
1
解决办法
5343
查看次数

标签 统计

beego ×1

go ×1