tags

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 8 Imported by: 9

Documentation

Index

Constants

View Source
const TagName = "tag"

Variables

This section is empty.

Functions

This section is empty.

Types

type Tag

type Tag struct {
	Name   string
	Values Values
}

Tag defines generic tag

func NewTag

func NewTag(name string, value interface{}) *Tag

NewTag creates a tag for supplied tag type

func (*Tag) Append

func (e *Tag) Append(value string)

Append appends tag value element

type Tags

type Tags []*Tag

Tags represents tags

func NewTags

func NewTags(tagLiteral string) Tags

NewTags create a tags for supplied tag literal

func Parse added in v0.4.0

func Parse(tagLiteral string) (Tags, error)

Parse parses an entire Go struct-tag literal. Unlike NewTags it rejects a malformed suffix and returns no usable prefix when parsing fails. Repeated tag names are retained; their semantics belong to the consuming owner.

func (*Tags) Append

func (t *Tags) Append(tag string, value string)

Append appends tag values to existing tag or create a new tag

func (Tags) Index

func (t Tags) Index(name string) int

Index returns matched by name tag index

func (Tags) Literal added in v0.4.0

func (t Tags) Literal() string

Literal renders a complete Go struct-tag literal, retaining explicitly empty values. Stringify keeps its historical omission behavior for existing users.

func (Tags) Lookup

func (t Tags) Lookup(name string) *Tag

Lookup returns matched by name tag

func (*Tags) Set

func (t *Tags) Set(tag string, value string)

Set sets tag value, if tag exists, overrides it

func (*Tags) SetIfNotFound

func (t *Tags) SetIfNotFound(tag string, value string)

func (*Tags) SetTag

func (t *Tags) SetTag(aTag *Tag)

SetTag sets tags, if tag exists, overrides it

func (Tags) Stringify

func (t Tags) Stringify() string

Stringify returns stringified tags representations

type Values

type Values string

Values represents tag values

func (Values) Match

func (v Values) Match(onMatch func(value string) error) error

Match matches elements separated by ,

func (Values) MatchPairs

func (v Values) MatchPairs(onMatch func(key, value string) error) error

MatchPairs matches pairs separated by commas, decoding Go-quoted values.

func (Values) MatchRawPairs added in v0.4.0

func (v Values) MatchRawPairs(onMatch func(key, value string) error) error

MatchRawPairs uses the same pair tokenizer as MatchPairs but preserves value delimiters. Callers can retain SQL identifier quoting without reparsing tags.

func (Values) Name

func (v Values) Name() (string, Values)

Name returns tag value and remaining values

Jump to

Keyboard shortcuts

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