utils

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2021 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KV

type KV interface {
	GetKey() interface{}
	GetValue() interface{}
}

type KVs

type KVs interface {
	GetValueOr(key interface{}, defValue interface{}) interface{}
	Contains(key interface{}) bool
	IfContains(key interface{}, action func(value interface{})) KVs
}

KVs interface

func NewKVs

func NewKVs(kvs ...KV) KVs

NewKVs creates the *KVs instance

type SimpleKV

type SimpleKV struct {
	Key   interface{}
	Value interface{}
}

SimpleKV is common structure to store key-value pairs. When you need something like Pair, you can use this

func (*SimpleKV) GetKey

func (s *SimpleKV) GetKey() interface{}

func (*SimpleKV) GetValue

func (s *SimpleKV) GetValue() interface{}

type SimpleKVs

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

SimpleKVs will store SimpleKV collection as map

func (*SimpleKVs) Contains

func (kvs *SimpleKVs) Contains(key interface{}) bool

Contains checks if a key exists

func (*SimpleKVs) GetValueOr

func (kvs *SimpleKVs) GetValueOr(key interface{}, defValue interface{}) interface{}

GetValueOr returns the value for a given key, if non-existent it returns defValue

func (*SimpleKVs) IfContains

func (kvs *SimpleKVs) IfContains(key interface{}, action func(value interface{})) KVs

IfContains invokes the action on a key if it exists

Jump to

Keyboard shortcuts

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