本文整理汇总了Golang中rter/data.User.StatusTime方法的典型用法代码示例。如果您正苦于以下问题:Golang User.StatusTime方法的具体用法?Golang User.StatusTime怎么用?Golang User.StatusTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rter/data.User
的用法示例。
在下文中一共展示了User.StatusTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: scanUser
func scanUser(user *data.User, rows *sql.Rows) error {
var createTimeString string
var updateTimeString string
var statusTimeString string
err := rows.Scan(
&user.Username,
&user.Password,
&user.Salt,
&user.Role,
&user.TrustLevel,
&createTimeString,
&user.Heading,
&user.Lat,
&user.Lng,
&updateTimeString,
&user.Status,
&statusTimeString,
)
if err != nil {
return err
}
// TODO: this is a hacky fix for null times
if createTimeString == "0000-00-00 00:00:00" {
createTimeString = "0001-01-01 00:00:00"
}
createTime, err := time.Parse("2006-01-02 15:04:05", createTimeString) // this assumes UTC as timezone
if err != nil {
log.Println("User scanner failed to parse create time.")
return err
}
user.CreateTime = createTime
// TODO: this is a hacky fix for null times
if updateTimeString == "0000-00-00 00:00:00" {
updateTimeString = "0001-01-01 00:00:00"
}
updateTime, err := time.Parse("2006-01-02 15:04:05", updateTimeString) // this assumes UTC as timezone
if err != nil {
log.Println("User scanner failed to parse update time.")
return err
}
user.UpdateTime = updateTime
// TODO: this is a hacky fix for null times
if statusTimeString == "0000-00-00 00:00:00" {
statusTimeString = "0001-01-01 00:00:00"
}
statusTime, err := time.Parse("2006-01-02 15:04:05", statusTimeString) // this assumes UTC as timezone
if err != nil {
log.Println("User scanner failed to parse time.")
return err
}
user.StatusTime = statusTime
return nil
}