structured

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Key      string
	RawValue string
	// contains filtered or unexported fields
}

Entry represents a struct tag entry. An entry is composed of a key and a value.

func (*Entry) String

func (e *Entry) String() string

String returns the string representation of the entry.

func (*Entry) Values

func (e *Entry) Values() (TagValues, error)

Values returns the values of the entry. When modifying the values, the result must be set [Entry.RawValue].

type Filler

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

Filler fills the tag from a struct tag.

func NewFiller

func NewFiller(escapeComma, allowDuplicateKeys bool) *Filler

NewFiller creates a new Filler.

func (*Filler) Data

func (f *Filler) Data() *Tag

Data returns the Tag filled by the struct tag content.

func (*Filler) Fill

func (f *Filler) Fill(key, value string) error

Fill fills the data from a struct tag.

type Options

type Options struct {
	// EscapeComma is used to escape the comma character within the value.
	EscapeComma bool

	// AllowDuplicateKeys allows duplicate keys.
	// NOT RECOMMENDED TO USE IT: this does not follow the struct tag conventions.
	AllowDuplicateKeys bool
}

Options for the parser.

type Tag

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

Tag represents a struct tag.

func NewTag

func NewTag(escapeComma, allowDuplicateKeys bool) *Tag

NewTag creates a new Tag.

func (*Tag) Add

func (t *Tag) Add(tag *Entry) error

Add adds a new entry to the Tag.

func (*Tag) Delete

func (t *Tag) Delete(key string)

Delete deletes the entry with the given key.

func (*Tag) Get

func (t *Tag) Get(key string) *Entry

Get returns the first entry with the given key.

func (*Tag) GetAll

func (t *Tag) GetAll(key string) []*Entry

GetAll returns all entries with the given key. NOT RECOMMENDED TO USE IT: this does not follow the struct tag conventions.

func (*Tag) IsEmpty

func (t *Tag) IsEmpty() bool

IsEmpty returns true if the Tag is empty.

func (*Tag) Seq

func (t *Tag) Seq() iter.Seq[*Entry]

Seq returns a sequence of entries.

func (*Tag) Sort

func (t *Tag) Sort()

Sort sorts the entries alphabetically by key.

func (*Tag) String

func (t *Tag) String() string

String returns the string representation of the Tag.

type TagValues

type TagValues []string

TagValues is a slice of values related to a key.

func (TagValues) Has

func (t TagValues) Has(value string) bool

Has checks if the values contain the given value.

func (TagValues) IsEmpty

func (t TagValues) IsEmpty() bool

IsEmpty returns true if the values are empty.

func (TagValues) String

func (t TagValues) String() string

String returns the string representation of the values.

Jump to

Keyboard shortcuts

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