如下图,中文数据显示为??
试过很多方法,比如调成UTF-8也不行,有没有大佬知道什么回事
![微信图片编辑_20210319120845.jpg](https://static.studygolang.com/210319/d59a3102c2b4742eb1f0579cb5fddd17.jpg)
package main
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
)
func main() {
db, _ := sql.Open("mysql", "root:123@tcp(localhost:3306)/test")
db.Ping()
defer func() {
db.Close()
}()
stmt, _ := db.Prepare("select id,name from go_test")
defer func() {
stmt.Close()
}()
rows, _ := stmt.Query()
defer func() {
rows.Close()
}()
var (
id int
name string
)
for rows.Next(){
rows.Scan(&id,&name)
fmt.Println(id,name)
}
}