代码如下:
func main() {
db, err := gorm.Open("mysql", "root:123456mh@/dbtest?charset=utf8&parseTime=True&loc=Local")
if err != nil {
panic("failed to connect mysql database")
}
defer db.Close()
rows, err := getCertainTimeTradeData(db, getBackCertainDay(2), getBackCertainDay(0))
if err != nil {
panic("query failed")
}
var domain string
var endtime time.Time
var price uint
var platform string
for rows.Next() {
rows.Scan(&domain, &endtime, &price, &platform)
fmt.Println(domain)
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…