package mymysql import ( "fmt" "testing" ) func TestMysql(t *testing.T) { err := InitDefault(&Config{ Dsn: "root:Tqa129126@tcp(119.29.187.200: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 CloseAll() var res = make(map[string]interface{}) err = Instance().Table("image").Limit(1).Take(&res).Error if err != nil { fmt.Println(err) return } fmt.Printf("%+v\n", res) }