github.com/wangyougui/gf/v2@v2.6.5/database/gdb/gdb_driver_default.go (about) 1 // Copyright GoFrame Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/wangyougui/gf. 6 7 package gdb 8 9 import ( 10 "database/sql" 11 ) 12 13 // DriverDefault is the default driver for mysql database, which does nothing. 14 type DriverDefault struct { 15 *Core 16 } 17 18 func init() { 19 if err := Register("default", &DriverDefault{}); err != nil { 20 panic(err) 21 } 22 } 23 24 // New creates and returns a database object for mysql. 25 // It implements the interface of gdb.Driver for extra database driver installation. 26 func (d *DriverDefault) New(core *Core, node *ConfigNode) (DB, error) { 27 return &DriverDefault{ 28 Core: core, 29 }, nil 30 } 31 32 // Open creates and returns an underlying sql.DB object for mysql. 33 // Note that it converts time.Time argument to local timezone in default. 34 func (d *DriverDefault) Open(config *ConfigNode) (db *sql.DB, err error) { 35 return 36 } 37 38 // PingMaster pings the master node to check authentication or keeps the connection alive. 39 func (d *DriverDefault) PingMaster() error { 40 return nil 41 } 42 43 // PingSlave pings the slave node to check authentication or keeps the connection alive. 44 func (d *DriverDefault) PingSlave() error { 45 return nil 46 }