代码拉取完成,页面将自动刷新
// Go driver for MySQL X Protocol
//
// Copyright 2016 Simon J Mudd.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at http://mozilla.org/MPL/2.0/.
//
// MySQL X protocol authentication using MYSQL41 method
package mysql
import (
"database/sql"
"database/sql/driver"
"net"
)
// This struct is exported to make the driver directly accessible.
// In general the driver is used via the database/sql package.
type XDriver struct{}
// DialFunc is a function which can be used to establish the network connection.
// Custom dial functions must be registered with RegisterDial
type DialFunc func(addr string) (net.Conn, error)
var dials map[string]DialFunc
// RegisterDial registers a custom dial function. It can then be used by the
// network address mynet(addr), where mynet is the registered new network.
// addr is passed as a parameter to the dial function.
func RegisterDial(net string, dial DialFunc) {
if dials == nil {
dials = make(map[string]DialFunc)
}
dials[net] = dial
}
func (d XDriver) Open(dsn string) (driver.Conn, error) {
var err error
cfg, err := parseDSN(dsn)
if err != nil {
return nil, err
}
cfg.useXProtocol = true // force X protocol as this driver was called explicitly
// New mysqlConn
mc := &mysqlXConn{
capabilities: NewServerCapabilities(),
cfg: NewXconfigFromConfig(cfg),
maxPacketAllowed: maxPacketSize,
maxWriteSize: maxPacketSize - 1,
}
return mc.Open2()
}
func init() {
sql.Register("mysql/xprotocol", &XDriver{})
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。