dsn

package
Version: v0.0.0-...-a494d39 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 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.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL