dsn

package
v0.0.0-...-9d95335 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 3 Imported by: 2

README

dsn parser

Parse string in the following format to a structure:

  1. user:pass@host:port/dbname
  2. user/pass@host:port/dbname
  3. user:pass@host/dbname
  4. user:pass@host
  5. user@host

Details:

  1. user is required
  2. host is required
  3. pass can be empty
  4. port can be empty
  5. dbname can be empty
  6. user and pass is separated by : or /
  7. host and port is separated by :
  8. dbname is at the end after / if it is not empty

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flag

type Flag struct {
	Username, Password, Host string
	Port                     int
	Database                 string
}

Flag is the datasource dsn structure.

func ParseFlag

func ParseFlag(source string) (dc *Flag, err error)

ParseFlag parses format like user:pass@host:port/db.

Jump to

Keyboard shortcuts

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