dsn

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: BSD-3-Clause Imports: 4 Imported by: 9 modules, 13 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

package dsn provides methods for working with data source name (DSN) strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DSN

type DSN map[string]string

DSN represents a data source name (DSN) style string. As with any Go map it is safe for concurrent reads (`Keys`, `String`, `Validate`) but not for concurrent writes, or writes concurrent with reads; callers sharing a `DSN` between goroutines must synchronize modifications themselves. `StringToDSN` and `StringToDSNWithKeys` return a new `DSN` on each call and are safe for concurrent use.

func StringToDSN

func StringToDSN(str_dsn string) (DSN, error)

StringToDSN parses 'str_dsn` in to a `DSN` instance. Pairs are separated by single spaces. A space or backslash in a key or value, and '=' in a key, may be escaped with a backslash.

func StringToDSNWithKeys

func StringToDSNWithKeys(str_dsn string, keys ...string) (DSN, error)

StringToDSNWithKeys parse 'str_dsn' in to a `DSN` instance ensuring that the instance contains keys matching 'keys'.

func (DSN) Keys

func (dsn DSN) Keys() []string

Keys returns the list of key names contained in 'dsn'.

func (DSN) String

func (dsn DSN) String() string

String returns a string representation of 'dsn'. Spaces and backslashes in keys and values, and '=' in keys, are escaped with a backslash so that values can not inject additional keys. `StringToDSN` reverses the escaping.

func (DSN) Validate added in v1.1.0

func (dsn DSN) Validate() error

Validate returns an error if 'dsn' can not be serialized by `String` and parsed again by `StringToDSN`. Keys and values are escaped by `String` so the only invalid DSN is one with an empty key.

Jump to

Keyboard shortcuts

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