xsql

package
v1.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaskPasswordInDSN

func MaskPasswordInDSN(dsn string) string

MaskPasswordInDSN masks the password within the MySQL data source name dsn. This function is usually used when displaying or logging the DSN.

When password is empty (not provided) the mask is added anyway. When the DSN is something that was not a DSN, the mask itself is returned to prevent possible mistakes.

func ReplaceDSNDatabase

func ReplaceDSNDatabase(dsn string, name string) (string, error)

ReplaceDSNDatabase takes dsn and replaces the database name. It returns the new Data Source Name.

func SetDSNOptions

func SetDSNOptions(dsn string, options map[string]string) (string, error)

SetDSNOptions sets parameters for the given dsn. This function will parse dsn, add options, and return a new formatted DSN.

Types

type DataSource

type DataSource struct {
	Driver   string
	User     string
	Password string
	Protocol string
	Address  string
	Schema   string
	Options  url.Values
}

func ParseDSN

func ParseDSN(name string) (*DataSource, error)

ParseDSN parsers the name as a data source name (DSN).

func (*DataSource) Format

func (d *DataSource) Format() string

func (*DataSource) String

func (d *DataSource) String() string

String returns a simplified representation of d. Simplified means that only username, protocol, address, and schema (if available) are included. The password is obfuscated.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL