我已經保存在我的數據庫(MySQL的)這個領域DATATIME,last_activity:2017-06-12 11:07:09
檢索日期時間從MySQL中了time.time在golang
即時通訊使用的帕拉姆parseTime=True
我OpenDB
的問題是,輸出是:last activity: {63632862429 0 <nil>}
而不是2017-06-12 11:07:09
我在做什麼錯?
感謝
type DateType time.Time
type User struct {
LastActivity DateType
}
func (stUser *User) GetUserDataByLogin(login string) {
db := OpenDB()
defer db.Close()
// Test the connection to the database
err := db.Ping()
checkErr(err)
err = db.QueryRow("SELECT last_activity FROM users WHERE login = ?", login).Scan(&stUser.LastActivity)
if err != nil {
if err == sql.ErrNoRows {
// there were no rows, but otherwise no error occurred
} else {
log.Fatal(err)
}
}
fmt.Println("last activity:", stUser.LastActivity)
}