kvstring

package
v0.1.48 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

kvstring package contains functions for representing string key:value pairs as one string and converting such strings to maps etc.

Index

Constants

View Source
const (
	KeyValueSeparator = "="
	FieldsSeparator   = ","
)

Variables

This section is empty.

Functions

func MapSubset

func MapSubset(m1, m2 map[string]string) bool

MapSubset returns whether m1 is subset of m2 (all m1's key-values are in m2 as well)

func MapsEquals

func MapsEquals(m1, m2 map[string]string) bool

MapsEquals returns whether m1 equals to m2

func RemoveCurlyBraces

func RemoveCurlyBraces(str string) (string, error)

RemoveCurlyBraces trims leading and trailing spaces and curly braces. For example input strings like ` { abc } ` will get as a result `abc` string

func SplitString

func SplitString(str string, kvSep, fldSep byte, buf []string) ([]string, error)

SplitString receves key-value string where the key-value separator is kvSep, and the pairs are separated by fldSep. For example in the string `name=app1,ip=1234` the kvSep is '=' and fldSep is ','. The SplitString expects the result buf which will be used for preparing result. key or value could contain fldSep or kvSep chars, if the value is put into quotes.

func ToMap

func ToMap(kvs string) (map[string]string, error)

ToMap turns a key-value string into map. For example the string `{ name=app, ccc="ddd" }` will be turned into a map, which equals to map[string]string{"name":"app", "ccc", "ddd"}

func TrimSpaces

func TrimSpaces(str string) string

trimSpaces removes leading and tailing spaces

Types

This section is empty.

Jump to

Keyboard shortcuts

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