package mysql import ( "regexp" ) func ParseSqlConnDBName(conn string) string { pattern := regexp.MustCompile( `^(?:(?P.*?)(?::(?P.*))?@)?` + // [user[:password]@] `(?:(?P[^\(]*)(?:\((?P[^\)]*)\))?)?` + // [net[(addr)]] `\/(?P.*?)` + // /dbname `(?:\?(?P[^\?]*))?$`) // [?param1=value1¶mN=valueN] matches := pattern.FindStringSubmatch(conn) // tlsConfigRegister := make(map[string]*tls.Config) names := pattern.SubexpNames() for i, match := range matches { switch names[i] { case "dbname": return match } } return "" }