var users []User // 查询 执行用Scan 和Find 一样 db=db.Raw("select uid,user_name,age from Users").Scan(&users) //db=db.Raw("select uid,user_name,age from Users").Find(&users) fmt.Println("Users",users) // 更新和删除.插入用 Exec db= db.Exec("update Users set user_name='def' where uid=?",1) fmt.Println("更新了",db.RowsAffected,"条数据") db= db.Exec("delete from Users where uid=?",2) fmt.Println("更新了",db.RowsAffected,"条数据") return int32(Mycount.Usercount)