tag

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: 7 Imported by: 0

Documentation

Overview

Package tag provides functions for working with tags.

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyLine = Line("")

	EmptySet = Set{"", emptyMap}
)

Functions

This section is empty.

Types

type Line

type Line string

func (Line) String

func (l Line) String() string

type Set

type Set struct {
	// contains filtered or unexported fields
}

func MapToSet

func MapToSet(mp map[string]string) Set

MapToSet receives a map of values mp and returns the Set of tags, formed from there.

func Parse

func Parse(tags string) (Set, error)

Parse parses tags and make a copy of tags

func ParseUnsafe

func ParseUnsafe(tags records.Record) (Set, error)

ParseUnsafe expects a string in format either "{name=value,name2=value...}" or "name=value,name2=value..." and returns the Set object or an error, if any. The ParseUnsafe forms the result from the string tags, and it tries to avoid new allocations. If the passed string is not safe

The value for any tag could be in escaped (double quoted by "). This case the value can contain the following symbols '{', '}', ',', '\', '"' escaped by backslash

func (*Set) Equals

func (s *Set) Equals(s1 Set) bool

Equals returns whether set s is equal to s1

func (*Set) IsEmpty

func (s *Set) IsEmpty() bool

IsEmpty returns true if the set is empty

func (*Set) Line

func (s *Set) Line() Line

Line returns formatted tags in sorted order

func (*Set) MarshalJSON

func (s *Set) MarshalJSON() ([]byte, error)

MarshalJSON to support json.Marshaller interface

func (*Set) String

func (s *Set) String() string

String returns line of tags

func (*Set) SubsetOf

func (s *Set) SubsetOf(s1 Set) bool

SubsetOf returns whether all tags from s present in s1

func (*Set) Tag

func (s *Set) Tag(tag string) string

Tag returns the tag value

func (*Set) UnmarshalJSON

func (s *Set) UnmarshalJSON(buf []byte) error

UnmarshalJSON to support json.Unmarshaller interface

Jump to

Keyboard shortcuts

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