File tree 2 files changed +13
-8
lines changed
2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ import (
20
20
"database/sql"
21
21
"database/sql/driver"
22
22
"net"
23
+ "os"
24
+ "strconv"
23
25
)
24
26
25
27
// This struct is exported to make the driver directly accessible.
@@ -30,6 +32,8 @@ type MySQLDriver struct{}
30
32
// Custom dial functions must be registered with RegisterDial
31
33
type DialFunc func (addr string ) (net.Conn , error )
32
34
35
+ var pid string
36
+
33
37
var dials map [string ]DialFunc
34
38
35
39
// 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) {
145
149
}
146
150
147
151
func init () {
152
+ pid = strconv .Itoa (os .Getpid ())
148
153
sql .Register ("mysql" , & MySQLDriver {})
149
154
}
Original file line number Diff line number Diff line change @@ -16,10 +16,9 @@ import (
16
16
"fmt"
17
17
"io"
18
18
"math"
19
- "os"
19
+ "os"
20
20
"path"
21
21
"runtime"
22
- "strconv"
23
22
"time"
24
23
)
25
24
@@ -238,12 +237,13 @@ func (mc *mysqlConn) writeAuthPacket(cipher []byte) error {
238
237
// User Password
239
238
scrambleBuff := scramblePassword (cipher , []byte (mc .cfg .passwd ))
240
239
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
+ }
247
247
248
248
attrlen := 0
249
249
for attrname , attrvalue := range attrs {
You can’t perform that action at this time.
0 commit comments