fields

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

Package fields provides a set of types and functions for working with fields.

Index

Constants

View Source
const CollectionSep = ", "

Variables

This section is empty.

Functions

This section is empty.

Types

type Dict

type Dict map[string]any

Dict is a dictionary of unique fields.

func (Dict) Add

func (d Dict) Add(fields ...Field)

Add adds fields to a Dict overwriting existing keys.

func (Dict) String

func (d Dict) String() string

String returns a string representation of a Dict in the `({key}={value}, {key}={value})` format.

func (Dict) ToList

func (d Dict) ToList() List

ToList converts a Dict to a List.

func (Dict) WriteTo

func (d Dict) WriteTo(b *strings.Builder)

WriteTo writes a string representation of a Dict to a given builder in the `({key}={value}, {key}={value})` format.

type Field

type Field struct {
	K string
	V any
}

Field is a generic key-value pair container.

func F

func F(key string, value any) Field

F is a shorthand for creating a new Field.

func (Field) String

func (f Field) String() string

String returns a string representation of a Field in the `{key}={value}` format.

func (Field) WriteTo

func (f Field) WriteTo(b *strings.Builder)

WriteTo writes a string representation of a Field to a given builder in the `{key}={value}`.

type List

type List []Field

List is list of fields in order of insertion.

func (*List) Add

func (l *List) Add(fields ...Field)

Add adds fields to a List, modifying it.

func (List) String

func (l List) String() string

String returns a string representation of a List in the `({key}={value}, {key}={value})` format.

func (List) ToDict

func (l List) ToDict() Dict

ToDict converts a List to a Dict overwriting existing keys.

func (List) WriteTo

func (l List) WriteTo(b *strings.Builder)

WriteTo writes a string representation of a List to a given builder in the `({key}={value}, {key}={value})` format.

Jump to

Keyboard shortcuts

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