bag

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendString

func AppendString(parameterBag bagcontract.ParameterBag, name string, value string) error

AppendString appends through the concrete bag's own critical section when it has one: the contract-level fallback reads and writes under two separate locks, and two concurrent appends through that window keep only one of the two values — a lost update no race detector reports, because each individual access is locked.

func AppendStringSlice

func AppendStringSlice(parameterBag bagcontract.ParameterBag, name string, values []string) error

func Bool

func Bool(parameterBag bagcontract.ParameterBag, name string) (bool, bool, error)

func Duration

func Duration(parameterBag bagcontract.ParameterBag, name string) (time.Duration, bool, error)

func Float64

func Float64(parameterBag bagcontract.ParameterBag, name string) (float64, bool, error)

func HasNonEmptyString

func HasNonEmptyString(parameterBag bagcontract.ParameterBag, name string) bool

func Int

func Int(parameterBag bagcontract.ParameterBag, name string) (int64, bool, error)

func String

func String(parameterBag bagcontract.ParameterBag, name string) (string, bool)

func StringAt

func StringAt(parameterBag bagcontract.ParameterBag, name string, index int) (string, bool, error)

func StringMapStringString

func StringMapStringString(parameterBag bagcontract.ParameterBag, name string) (map[string]string, bool, error)

func StringOrDefault

func StringOrDefault(parameterBag bagcontract.ParameterBag, name string, defaultValue string) string

func StringSlice

func StringSlice(parameterBag bagcontract.ParameterBag, name string) ([]string, bool)

func StringSliceStrict

func StringSliceStrict(parameterBag bagcontract.ParameterBag, name string) ([]string, bool, error)

func StringStrict

func StringStrict(parameterBag bagcontract.ParameterBag, name string) (string, bool, error)

Types

type ParameterBag

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

func NewParameterBag

func NewParameterBag() *ParameterBag

func NewParameterBagFromValues

func NewParameterBagFromValues(values url.Values) *ParameterBag

NewParameterBagFromValues keeps the single and the repeated key apart by type: url.Values carries every value as a list even when the key appeared once, so a key with one occurrence is stored as the string it really is — which is what lets String and Input hand it back — while a genuinely repeated key stays a string slice, to be read through StringSlice or StringAt. Reading the repeated one as a single string is refused loudly rather than answered with a guess.

func (*ParameterBag) All

func (instance *ParameterBag) All() map[string]any

All copies as deep as the bag's own writers go: a string slice or a string map handed back live would alias the stored value, and a caller mutating the copy would write into the bag behind its lock. Other value types are opaque to the bag and are handed back as stored.

func (*ParameterBag) AppendString added in v1.19.0

func (instance *ParameterBag) AppendString(name string, value string) error

AppendString adds one string under the name inside a single critical section: the read-modify-write helper of the same name works over the contract through Get and Set, whose window between the two locks loses one of two concurrent appends without an error — a lost update the race detector cannot see, because every individual access is locked.

func (*ParameterBag) Count

func (instance *ParameterBag) Count() int

func (*ParameterBag) Get

func (instance *ParameterBag) Get(name string) (any, bool)

func (*ParameterBag) Has

func (instance *ParameterBag) Has(name string) bool

func (*ParameterBag) Remove

func (instance *ParameterBag) Remove(name string)

func (*ParameterBag) Set

func (instance *ParameterBag) Set(name string, value any)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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