github.com/wangyougui/gf/v2@v2.6.5/database/gdb/gdb_driver_wrapper.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  // DriverWrapper is a driver wrapper for extending features with embedded driver.
    10  type DriverWrapper struct {
    11  	driver Driver
    12  }
    13  
    14  // New creates and returns a database object for mysql.
    15  // It implements the interface of gdb.Driver for extra database driver installation.
    16  func (d *DriverWrapper) New(core *Core, node *ConfigNode) (DB, error) {
    17  	db, err := d.driver.New(core, node)
    18  	if err != nil {
    19  		return nil, err
    20  	}
    21  	return &DriverWrapperDB{
    22  		DB: db,
    23  	}, nil
    24  }
    25  
    26  // newDriverWrapper creates and returns a driver wrapper.
    27  func newDriverWrapper(driver Driver) Driver {
    28  	return &DriverWrapper{
    29  		driver: driver,
    30  	}
    31  }