如下图,中文数据显示为??
试过很多方法,比如调成UTF-8也不行,有没有大佬知道什么回事
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 gotest") 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)
}
}