File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed
Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ import (
2020 "database/sql"
2121 "database/sql/driver"
2222 "net"
23+ "os"
24+ "strconv"
2325)
2426
2527// This struct is exported to make the driver directly accessible.
@@ -30,6 +32,8 @@ type MySQLDriver struct{}
3032// Custom dial functions must be registered with RegisterDial
3133type DialFunc func (addr string ) (net.Conn , error )
3234
35+ var pid string
36+
3337var dials map [string ]DialFunc
3438
3539// RegisterDial registers a custom dial function. It can then be used by the
@@ -145,5 +149,6 @@ func (d MySQLDriver) Open(dsn string) (driver.Conn, error) {
145149}
146150
147151func init () {
152+ pid = strconv .Itoa (os .Getpid ())
148153 sql .Register ("mysql" , & MySQLDriver {})
149154}
Original file line number Diff line number Diff line change @@ -16,10 +16,9 @@ import (
1616 "fmt"
1717 "io"
1818 "math"
19- "os"
19+ "os"
2020 "path"
2121 "runtime"
22- "strconv"
2322 "time"
2423)
2524
@@ -238,12 +237,13 @@ func (mc *mysqlConn) writeAuthPacket(cipher []byte) error {
238237 // User Password
239238 scrambleBuff := scramblePassword (cipher , []byte (mc .cfg .passwd ))
240239
241- attrs := make (map [string ]string )
242- attrs ["_os" ] = runtime .GOOS
243- attrs ["_client_name" ] = "Go MySQL Driver"
244- attrs ["_pid" ] = strconv .Itoa (os .Getpid ())
245- attrs ["_platform" ] = runtime .GOARCH
246- attrs ["program_name" ] = path .Base (os .Args [0 ])
240+ attrs := map [string ]string {
241+ "_os" : runtime .GOOS ,
242+ "_client_name" : "Go-MySQL-Driver" ,
243+ "_pid" : pid ,
244+ "_platform" : runtime .GOARCH ,
245+ "program_name" : path .Base (os .Args [0 ]),
246+ }
247247
248248 attrlen := 0
249249 for attrname , attrvalue := range attrs {
You can’t perform that action at this time.
0 commit comments