maputil: Index | Files

package maputil

import ""


Package Files

error.go flatten.go map.go sql.go


var (
    // ErrInvalidType represents an invalid configuration value type error.
    ErrInvalidType = errors.New("invalid value type")
    // ErrUnscannableValue represents an unscannable value error.
    ErrUnscannableValue = errors.New("unscannable value")

type Map Uses

type Map map[string]interface{}

Map represents an instance of keys mapping.

All the function returning values associated with keys will return a fallback value if the key is not present in the map or if the value can't be converted to the requested type.

func (Map) Clone Uses

func (m Map) Clone() Map

Clone returns a clone of the keys mapping instance.

func (Map) Flatten Uses

func (m Map) Flatten(glue string) map[string]string

Flatten returns a "flattened" version of the map. * all nested elements are moved at the top level, with sub-level keys prefixed with the original key name using the glue string * any value whose type is different than maps or slice is returned as string representation (fmt "%v" verb) * slice elements are flattened, with their numeric index value as suffix * any pointer value is dereferenced

func (Map) GetBool Uses

func (m Map) GetBool(key string, fallback bool) (bool, error)

GetBool returns the boolean value associated with a key.

func (Map) GetFloat Uses

func (m Map) GetFloat(key string, fallback float64) (float64, error)

GetFloat returns the floating-point number value associated with a key.

func (Map) GetInt Uses

func (m Map) GetInt(key string, fallback int) (int, error)

GetInt returns the integer value associated with a key.

func (Map) GetInt64 Uses

func (m Map) GetInt64(key string, fallback int64) (int64, error)

GetInt64 returns the 64-bit integer value associated with a key.

func (Map) GetInterface Uses

func (m Map) GetInterface(key string, fallback interface{}) (interface{}, error)

GetInterface returns the interface value associated with a key.

func (Map) GetMap Uses

func (m Map) GetMap(key string, fallback Map) (Map, error)

GetMap returns the map value associated with a key.

func (Map) GetString Uses

func (m Map) GetString(key, fallback string) (string, error)

GetString returns the string value associated with a key.

func (Map) GetStringSlice Uses

func (m Map) GetStringSlice(key string, fallback []string) ([]string, error)

GetStringSlice returns the string value associated with a key.

func (Map) Has Uses

func (m Map) Has(key string) bool

Has returns true if key is present in the mapping, false otherwise.

func (*Map) Merge Uses

func (m *Map) Merge(source Map, replace bool)

Merge merges the source map entries into the receiver map. If replace parameter is true, existing entries in the receiver map will be replaced with entries from the source map.

func (*Map) Scan Uses

func (m *Map) Scan(v interface{}) error

Scan unmarshals the keys mapping retrieved from SQL drivers.

func (Map) Set Uses

func (m Map) Set(k string, v interface{})

Set sets the mapping key k to the value v.

func (Map) Value Uses

func (m Map) Value() (driver.Value, error)

Value marshals the keys mapping for compatibility with SQL drivers.

Package maputil imports 5 packages (graph) and is imported by 10 packages. Updated 2019-03-19. Refresh now. Tools for package owners.