Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ type MySQLDriver struct{}
type DialFunc func(addr string) (net.Conn, error)

var pid string
var os_user string
var os_user_full string
var osUser string
var osUserFull string

var dials map[string]DialFunc

Expand Down Expand Up @@ -171,10 +171,10 @@ func handleAuthResult(mc *mysqlConn, cipher []byte) error {

func init() {
pid = strconv.Itoa(os.Getpid())
os_user_entry, err := user.Current()
osUserEntry, err := user.Current()
if err == nil {
os_user_full = os_user_entry.Name
os_user = os_user_entry.Username
osUserFull = osUserEntry.Name
osUser = osUserEntry.Username
}
sql.Register("mysql", &MySQLDriver{})
}
8 changes: 4 additions & 4 deletions packets.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,11 @@ func (mc *mysqlConn) writeAuthPacket(cipher []byte) error {
"_platform": runtime.GOARCH,
"program_name": path.Base(os.Args[0]),
}
if len(os_user_full) > 0 {
attrs["_os_user_full"] = os_user_full
if len(osUserFull) > 0 {
attrs["_os_user_full"] = osUserFull
}
if len(os_user) > 0 {
attrs["_os_user"] = os_user
if len(osUser) > 0 {
attrs["_os_user"] = osUser
}

// Merge the custom attributes and the default attributes
Expand Down