github.com/hellobchain/third_party@v0.0.0-20230331131523-deb0478a2e52/go-sql-driver/mysql/driver_go110.go (about)

     1  // Go MySQL Driver - A MySQL-Driver for Go's database/sql package
     2  //
     3  // Copyright 2018 The Go-MySQL-Driver Authors. All rights reserved.
     4  //
     5  // This Source Code Form is subject to the terms of the Mozilla Public
     6  // License, v. 2.0. If a copy of the MPL was not distributed with this file,
     7  // You can obtain one at http://mozilla.org/MPL/2.0/.
     8  
     9  // +build go1.10
    10  
    11  package mysql
    12  
    13  import (
    14  	"database/sql/driver"
    15  )
    16  
    17  // NewConnector returns new driver.Connector.
    18  func NewConnector(cfg *Config) (driver.Connector, error) {
    19  	cfg = cfg.Clone()
    20  	// normalize the contents of cfg so calls to NewConnector have the same
    21  	// behavior as MySQLDriver.OpenConnector
    22  	if err := cfg.normalize(); err != nil {
    23  		return nil, err
    24  	}
    25  	return &connector{cfg: cfg}, nil
    26  }
    27  
    28  // OpenConnector implements driver.DriverContext.
    29  func (d MySQLDriver) OpenConnector(dsn string) (driver.Connector, error) {
    30  	cfg, err := ParseDSN(dsn)
    31  	if err != nil {
    32  		return nil, err
    33  	}
    34  	return &connector{
    35  		cfg: cfg,
    36  	}, nil
    37  }