attributes

package
v1.20.95 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: Zlib Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attributes

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

Attributes is an immutable struct for storing and retrieving generic key/value pairs. Keys must be hashable, and users should define their own types for keys.

func New

func New(kvs ...interface{}) *Attributes

New returns a new Attributes containing all key/value pairs in kvs. If the same key appears multiple times, the last value overwrites all previous values for that key. Panics if len(kvs) is not even.

func (*Attributes) For

func (a *Attributes) For(call func(key interface{}, val interface{}))

func (*Attributes) Value

func (a *Attributes) Value(key interface{}) interface{}

Value returns the value associated with these attributes for key, or nil if no value is associated with key.

func (*Attributes) WithValues

func (a *Attributes) WithValues(kvs ...interface{}) *Attributes

WithValues returns a new Attributes containing all key/value pairs in a and kvs. Panics if len(kvs) is not even. If the same key appears multiple times, the last value overwrites all previous values for that key. To remove an existing key, use a nil value.

type KV added in v0.5.2

type KV struct {
	Key interface{} `json:"key"`
	Val interface{} `json:"value"`
}

Jump to

Keyboard shortcuts

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