初始化实现
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"code.yun.ink/pkg/mysqlx"
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm/logger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
client, err := mysqlx.NewDB(
|
||||
mysqlx.WithDialector(sqlite.Open("file::memory:?cache=shared")),
|
||||
mysqlx.WithLogger(logger.Default.LogMode(logger.Info)),
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to create mysqlx client with custom dialector: %v", err)
|
||||
}
|
||||
defer client.Close()
|
||||
|
||||
fmt.Println("MySQL SDK client created with custom Dialector")
|
||||
_ = client
|
||||
}
|
||||
Reference in New Issue
Block a user