values

package
v0.0.0-...-f196629 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddInt

func AddInt(vs Updater, key string, step int) int

AddInt adds step to key, returns the result as int. If the value of key is not exist or other error, value is set to step.

func AddInt64

func AddInt64(vs Updater, key string, step int64) int64

AddInt64 adds step to key, returns the result as int64. If the value of key is not exist or other error, value is set to step.

func AddUint

func AddUint(vs Updater, key string, step uint) uint

AddUint adds step to key, returns the result as uint. If the value of key is not exist or other error, value is set to step.

func AddUint64

func AddUint64(vs Updater, key string, step uint64) uint64

AddUint64 adds step to key, returns the result as uint64. If the value of key is not exist or other error, value is set to step.

func Append

func Append(dst Setter, src Ranger)

Appends all the values from src, it replaces any existing values.

func Get

func Get(vs Getter, key string) reflectx.Value

GetValue gets the value associated with the given key. If there are no values associated with the key, GetValue returns a nil value.

func Getsert

func Getsert(vs Updater, key string, constructor func() interface{}) interface{}

If key does not exsit, create a new one by constructor.

func Plus

func Plus(vs Updater, key string, step interface{}) (result reflectx.Value)

Plus adds step to v and returns the result. The return value has the same type with the value associated with the given key. It panics if step is not numberical. If v is nil, step will be returned.

Types

type Form

type Form map[string][]string

func (Form) AddString

func (m Form) AddString(key, value string)

Add adds the value to key. It appends to any existing values associated with key.

func (Form) AddValues

func (m Form) AddValues(key string, values ...interface{})

func (*Form) Decode

func (m *Form) Decode(b []byte) error

Decode parses the URL-encoded query string and returns a map listing the values specified for each key.

func (Form) Encode

func (m Form) Encode() ([]byte, error)

Encode encodes the values into URL-encoded form ("bar=baz&foo=quux") sorted by key.

func (Form) Get

func (m Form) Get(key string) interface{}

Get value from values, it returns nil in case of non-existed.

func (Form) Len

func (m Form) Len() int

func (Form) Range

func (m Form) Range(f func(key string, value interface{}) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

func (Form) Remove

func (m Form) Remove(key string)

Del deletes the values associated with key.

func (*Form) RemoveAll

func (m *Form) RemoveAll()

func (Form) Set

func (m Form) Set(key string, value interface{})

Set sets the key to value. It replaces any existing values.

func (Form) SetValues

func (m Form) SetValues(key string, values ...interface{})

func (Form) Update

func (m Form) Update(key string, fn func(interface{}) interface{}) interface{}

Get the value of key, use it as input parameter to call fn. If the return value of fn is not nil, save it with key. Update returns the value of key in the end.

func (Form) ValueOf

func (m Form) ValueOf(key string) reflectx.Value

ValueOf gets the reflectx.Value associated with the given key. If there are no values associated with the key, ValueOf should return a nil Value.

type Getter

type Getter interface {
	// Get value from values, it returns nil in case of non-existed.
	Get(key string) interface{}
}

type JsonMap

type JsonMap map[string]interface{}

func (*JsonMap) Decode

func (m *JsonMap) Decode(b []byte) error

func (JsonMap) Encode

func (m JsonMap) Encode() ([]byte, error)

func (JsonMap) Get

func (m JsonMap) Get(key string) interface{}

Get value from values, it returns nil in case of non-existed.

func (JsonMap) Len

func (m JsonMap) Len() int

func (JsonMap) Range

func (m JsonMap) Range(f func(key string, value interface{}) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

func (JsonMap) Remove

func (m JsonMap) Remove(key string)

Del deletes the values associated with key.

func (*JsonMap) RemoveAll

func (m *JsonMap) RemoveAll()

func (JsonMap) Set

func (m JsonMap) Set(key string, value interface{})

Set sets the key to value. It replaces any existing values.

func (JsonMap) Update

func (m JsonMap) Update(key string, fn func(interface{}) interface{}) interface{}

Get the value of key, use it as input parameter to call fn. If the return value of fn is not nil, save it with key. Update returns the value of key in the end.

func (JsonMap) ValueOf

func (m JsonMap) ValueOf(key string) reflectx.Value

ValueOf gets the reflectx.Value associated with the given key. If there are no values associated with the key, ValueOf should return a nil Value.

type Ranger

type Ranger interface {
	// Range calls f sequentially for each key and value present in the map.
	// If f returns false, range stops the iteration.
	Range(f func(key string, value interface{}) bool)
}

type SafeMap

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

func NewSafeMap

func NewSafeMap(typ string, data map[string]interface{}) *SafeMap

func (*SafeMap) Decode

func (m *SafeMap) Decode(b []byte) error

func (*SafeMap) Encode

func (m *SafeMap) Encode() ([]byte, error)

func (*SafeMap) Get

func (m *SafeMap) Get(key string) interface{}

Get value from values, it returns nil in case of non-existed.

func (*SafeMap) Len

func (m *SafeMap) Len() int

func (*SafeMap) LockGuard

func (m *SafeMap) LockGuard(f func(data map[string]interface{}))

safe call

func (*SafeMap) Range

func (m *SafeMap) Range(f func(key string, value interface{}) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

func (*SafeMap) Remove

func (m *SafeMap) Remove(key string)

Del deletes the values associated with key.

func (*SafeMap) RemoveAll

func (m *SafeMap) RemoveAll()

func (*SafeMap) Set

func (m *SafeMap) Set(key string, value interface{})

Set sets the key to value. It replaces any existing values.

func (*SafeMap) Update

func (m *SafeMap) Update(key string, fn func(interface{}) interface{}) interface{}

Get the value of key, use it as input parameter to call fn. If the return value of fn is not nil, save it with key. Update returns the value of key in the end.

func (*SafeMap) ValueOf

func (m *SafeMap) ValueOf(key string) reflectx.Value

ValueOf gets the reflect.Value associated with the given key. If there are no values associated with the key, ValueOf should return a nil Value.

type Setter

type Setter interface {
	// Set sets the key to value. It replaces any existing values.
	Set(key string, value interface{})
}

type Updater

type Updater interface {
	// Get the value of key, use it as input parameter to call fn.
	// If the return value of fn is not nil, save it with key.6
	// Update returns the value of key in the end.
	Update(key string, fn func(interface{}) interface{}) interface{}
}

type Values

type Values interface {
	Getter
	Setter
	Updater
	Ranger

	// ValueOf gets the reflectx.Value associated with the given key.
	// If there are no values associated with the key, ValueOf should return
	// a nil Value.
	ValueOf(key string) reflectx.Value
	Encode() ([]byte, error)
	Decode([]byte) error

	// Removes the values associated with key.
	Remove(key string)
	RemoveAll()
	Len() int
}

Jump to

Keyboard shortcuts

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