Documentation ¶
Index ¶
- Constants
- Variables
- func GetSocket(ctx context.Context, dsn string) (string, error)
- func GetSocketFromNetstat(ctx context.Context) (string, error)
- func GetSocketFromProcessList(ctx context.Context) (string, error)
- func GetSocketFromTCPConnection(ctx context.Context, dsn string) (socket string, err error)
- func GetSocketsFromPID(ctx context.Context, pid string) ([]string, error)
- func HidePassword(dsn string) string
- type DSN
Constants ¶
const ( ParseTimeParam = "parseTime=true" TimezoneParam = `time_zone='%2b00%3a00'` LocationParam = "loc=UTC" OldPasswordsParam = "allowOldPasswords=true" HiddenPassword = "***" )
Variables ¶
var ( // ErrNoSocket is returned when GetSocketFromProcessLists can't locate socket. ErrNoSocket = errors.New("cannot auto-detect MySQL socket") )
Functions ¶
func GetSocketFromNetstat ¶
GetSocketFromNetstat will loop through list of open sockets and try to find one matching `mysql` word. Warning: this function returns the socket for the FIRST entry it founds. If there are more sockets containing `mysql` word, only the first one will be detected.
func GetSocketFromProcessList ¶
GetSocketFromProcessList will loop through the list of PIDs until it finds a process named 'mysqld' and the it will try to get the socket by querying the open network connections for that process. Warning: this function returns the socket for the FIRST mysqld process it founds. If there are more than one MySQL instance, only the first one will be detected.
func GetSocketFromTCPConnection ¶
GetSocketFromTCPConnection will try to get socket path by connecting to MySQL localhost TCP port. This is not reliable as TCP connections may be not allowed.
func GetSocketsFromPID ¶
GetSocketsFromPID returns currently open UNIX domain socket files by process identifier (PID).