我有一个名为package_redeem的表和一个名为TIMESTAMP的名为expire_at的字段
我的Go方法检索值如下
// RetrieveRedeemRecord will Retrieve a RedeemCode Record by Code; R of CRUD
func RetrieveRedeemRecord(code string) (anyError error) {
var thisWorks mysql.NullTime
var thisOneNotWork sql.NullTime
stmtStr := `SELECT expire_at FROM package_redeem WHERE code=?`
anyError = dbhelper.GetDB().QueryRow(stmtStr, code).Scan(&thisOneNotWork)
switch anyError {
case nil:
case sql.ErrNoRows:
log.Println("no row found with ", code)
default:
log.Panic("errRow(s) ", anyError.Error())
}
return anyError
}
奇怪的是,使用sql.NullTime类型会感到恐慌!
panic: errRow(s) sql: Scan error on column index 5, name "updated_at": unsupported Scan, storing driver.Value type []uint8 into type *time.Time [recovered]
panic: errRow(s) sql: Scan error on column index 5, name "updated_at": unsupported Scan, storing driver.Value type []uint8 into type *time.Time
但是使用mysql.NullTime类型可以工作,我想从Go1.3开始,mysql.NullTime就是sql.NullTime。我在这里想念东西吗?