34 lines
617 B
Go
34 lines
617 B
Go
package mymysql
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestMysql(t *testing.T) {
|
|
myDB, err := NewDefault(&Config{
|
|
Dsn: "root:root@tcp(127.0.0.1:3306)/site?loc=Local&charset=utf8mb4&writeTimeout=3s&readTimeout=3s&timeout=2s&parseTime=true",
|
|
MaxOpenConn: 16,
|
|
MaxIdleConn: 4,
|
|
MaxIdleTime: "5m",
|
|
MaxLifeTime: "30m",
|
|
Debug: false,
|
|
GormLogger: nil,
|
|
})
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
|
|
defer myDB.Close()
|
|
|
|
var res = make(map[string]interface{})
|
|
err = myDB.db.Table("image").Limit(1).Take(&res).Error
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
|
|
fmt.Printf("%+v\n", res)
|
|
}
|