luci: Index | Examples | Files

package strpair

import ""

Package strpair implements parsing and formatting of lists of colon-delimited key-value pair strings.

Example of pairs:




Package Files


func Format Uses

func Format(k, v string) string

Format formats a pair from a key and a value.

func Parse Uses

func Parse(pair string) (k, v string)

Parse parses a colon-delimited key-value pair.

If pair does not have ":", the whole string becomes the key with an empty value.


pairs := []string{
tags := ParseMap(ParseMap(pairs)["swarming_tag"])



type Map Uses

type Map map[string][]string

Map contains parsed string pairs.

func ParseMap Uses

func ParseMap(raw []string) Map

ParseMap parses a list of colon-delimited key-value pair strings.

func (Map) Add Uses

func (m Map) Add(key, value string)

Add adds the value to key. It appends to any existing values associated with key.

func (Map) Contains Uses

func (m Map) Contains(key, value string) bool

Contains returns true if m contains the key-value pair.

func (Map) Copy Uses

func (m Map) Copy() Map

Copy returns a deep copy of m.

func (Map) Del Uses

func (m Map) Del(key string)

Del deletes the values associated with key.

func (Map) Format Uses

func (m Map) Format() []string

Format converts m to a sorted list of strings.

func (Map) Get Uses

func (m Map) Get(key string) string

Get gets the first value associated with the given key. If there are no values associated with the key, Get returns the empty string. To access multiple values, use the map directly.

func (Map) Set Uses

func (m Map) Set(key, value string)

Set sets the key to value. It replaces any existing values.

Package strpair imports 2 packages (graph) and is imported by 23 packages. Updated 2020-12-06. Refresh now. Tools for package owners.