structs

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: MIT Imports: 11 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustToMap added in v0.4.2

func MustToMap(st interface{}) map[string]interface{}

MustToMap alis of TryToMap, but will panic on error

func ParseReflectTags added in v0.3.10

func ParseReflectTags(rt reflect.Type, tagNames []string) (map[string]maputil.SMap, error)

ParseReflectTags parse struct tags info.

func ParseTagValueINI added in v0.3.13

func ParseTagValueINI(field, tagStr string) (mp maputil.SMap, err error)

ParseTagValueINI tag value string. is like INI format data

eg: "name=int0;shorts=i;required=true;desc=int option message"

func ParseTags added in v0.3.10

func ParseTags(v interface{}, tagNames []string) (map[string]maputil.SMap, error)

ParseTags for parse struct tags.

func ToMap added in v0.4.2

func ToMap(st interface{}) map[string]interface{}

ToMap simple convert structs to map by reflect

func TryToMap added in v0.4.2

func TryToMap(st interface{}) (map[string]interface{}, error)

TryToMap simple convert structs to map by reflect

Types

type Aliases

type Aliases struct {

	// Checker custom add alias name checker func
	Checker func(alias string) // should return bool OR error ??
	// contains filtered or unexported fields
}

Aliases implemented an simple string alias map.

func NewAliases

func NewAliases(checker func(alias string)) *Aliases

NewAliases create

func (*Aliases) AddAlias

func (as *Aliases) AddAlias(real, alias string)

AddAlias to the Aliases

func (*Aliases) AddAliasMap

func (as *Aliases) AddAliasMap(alias2real map[string]string)

AddAliasMap to the Aliases

func (*Aliases) AddAliases

func (as *Aliases) AddAliases(real string, aliases []string)

AddAliases to the Aliases

func (*Aliases) HasAlias

func (as *Aliases) HasAlias(alias string) bool

HasAlias in the Aliases

func (*Aliases) Mapping

func (as *Aliases) Mapping() map[string]string

Mapping get all aliases mapping

func (*Aliases) ResolveAlias

func (as *Aliases) ResolveAlias(alias string) string

ResolveAlias by given name.

type MapDataStore added in v0.3.13

type MapDataStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

MapDataStore struct

func NewMapData added in v0.3.13

func NewMapData() *MapDataStore

NewMapData create

func (*MapDataStore) BoolVal added in v0.5.3

func (md *MapDataStore) BoolVal(key string) bool

BoolVal get from data

func (*MapDataStore) Clear added in v0.5.3

func (md *MapDataStore) Clear()

Clear all data

func (*MapDataStore) Data added in v0.3.13

func (md *MapDataStore) Data() map[string]interface{}

Data get all

func (*MapDataStore) EnableLock added in v0.3.13

func (md *MapDataStore) EnableLock() *MapDataStore

EnableLock for operate data

func (*MapDataStore) Get added in v0.5.5

func (md *MapDataStore) Get(key string) interface{}

Get val from data

func (*MapDataStore) GetVal added in v0.5.3

func (md *MapDataStore) GetVal(key string) interface{}

GetVal get from data

func (*MapDataStore) IntVal added in v0.5.3

func (md *MapDataStore) IntVal(key string) int

IntVal get from data

func (*MapDataStore) Len added in v0.5.3

func (md *MapDataStore) Len() int

Len of data

func (*MapDataStore) Set added in v0.5.5

func (md *MapDataStore) Set(key string, val interface{})

Set value to data

func (*MapDataStore) SetData added in v0.3.13

func (md *MapDataStore) SetData(data map[string]interface{})

SetData set all data

func (*MapDataStore) SetValue added in v0.3.13

func (md *MapDataStore) SetValue(key string, val interface{})

SetValue to data

func (*MapDataStore) StrVal added in v0.5.3

func (md *MapDataStore) StrVal(key string) string

StrVal get from data

func (*MapDataStore) String added in v0.5.3

func (md *MapDataStore) String() string

String format data

func (*MapDataStore) Value added in v0.3.13

func (md *MapDataStore) Value(key string) (val interface{}, ok bool)

Value get from data

type TagParser added in v0.3.10

type TagParser struct {
	TagNames string

	Func func(tagVal string) map[string]string
}

TagParser struct

type Value added in v0.5.5

type Value struct {
	// V value
	V interface{}
}

Value data store

func NewValue added in v0.5.5

func NewValue(val interface{}) *Value

NewValue instance.

func (Value) Bool added in v0.5.5

func (v Value) Bool() bool

Bool value

func (Value) Float64 added in v0.5.5

func (v Value) Float64() float64

Float64 value

func (Value) Int added in v0.5.5

func (v Value) Int() int

Int value get

func (Value) Int64 added in v0.5.5

func (v Value) Int64() int64

Int64 value

func (Value) IsEmpty added in v0.5.5

func (v Value) IsEmpty() bool

IsEmpty value

func (*Value) Reset added in v0.5.5

func (v *Value) Reset()

Reset value

func (*Value) Set added in v0.5.5

func (v *Value) Set(val interface{})

Set value

func (Value) SplitToInts added in v0.5.6

func (v Value) SplitToInts(sep ...string) (ss []int)

SplitToInts split string value to []int

func (Value) SplitToStrings added in v0.5.6

func (v Value) SplitToStrings(sep ...string) (ss []string)

SplitToStrings split string value to strings

func (Value) String added in v0.5.5

func (v Value) String() string

String value

func (Value) Strings added in v0.5.5

func (v Value) Strings() (ss []string)

Strings value

func (Value) Val added in v0.5.5

func (v Value) Val() interface{}

Val get

Jump to

Keyboard shortcuts

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