dtype

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2021 License: MIT Imports: 8 Imported by: 0

README

dtype

Dynamic Types Conversion

Documentation

Index

Constants

View Source
const (
	JoinKeys                  JoinType = 1 << iota // k
	JoinValues                                     // v
	JoinMySqlValues                                // "v"
	JoinKV                                         //kv
	JoinJSON                                       // "k":"v"
	JoinMySQL                                      // `t`.`k`="v"
	JoinMySqlFullLike                              // `t`.`k` LIKE "%v%"
	JoinMySqlStartWith                             // `t`.`k` LIKE "v%"
	JoinMySqlEndWith                               // `t`.`k` LIKE "%v"
	JoinMySqlLessThan                              // `t`.`k` < "v"
	JoinMySqlGreaterThan                           // `t`.`k` > "v"
	JoinMySqlGreaterOrEqualTo                      // `t`.`k` >= "v"
	JoinMySqlLessOrEqualTo                         // `t`.`k` <= "v"
	JoinURL                                        // k=v
	JoinSortedValues          = JoinSortedBit | JoinValues
	JoinSortedMySqlValues     = JoinSortedBit | JoinMySqlValues
	JoinSortedKV              = JoinSortedBit | JoinKV
	JoinSortedJSON            = JoinSortedBit | JoinJSON
	JoinSortedMySQL           = JoinSortedBit | JoinMySQL
	JoinSortedURL             = JoinSortedBit | JoinURL
)

Variables

This section is empty.

Functions

func Bool

func Bool(d interface{}, errs ...error) (bool, error)

func BoolItem

func BoolItem(arr []interface{}, i int) bool

func Bytes

func Bytes(d interface{}, errs ...error) []byte

func Float32

func Float32(d interface{}, errs ...error) (float32, error)

func Float32Item

func Float32Item(arr []interface{}, i int) float32

func Float64

func Float64(d interface{}, errs ...error) (float64, error)

func Float64Item

func Float64Item(arr []interface{}, i int) float64

func Int

func Int(d interface{}, errs ...error) (int, error)

func Int16

func Int16(d interface{}, errs ...error) (int16, error)

func Int16Item

func Int16Item(arr []interface{}, i int) int16

func Int32

func Int32(d interface{}, errs ...error) (int32, error)

func Int32Item

func Int32Item(arr []interface{}, i int) int32

func Int64

func Int64(d interface{}, errs ...error) (int64, error)

func Int64Item

func Int64Item(arr []interface{}, i int) int64

func Int8

func Int8(d interface{}, errs ...error) (int8, error)

func Int8Item

func Int8Item(arr []interface{}, i int) int8

func IsEmpty

func IsEmpty(d interface{}, errs ...error) bool

func JoinByNames

func JoinByNames(u interface{}, ty JoinType, sep string, names ...string) string

func JoinByTags

func JoinByTags(u interface{}, ty JoinType, sep string, tagname string, tags ...string) (ret string)

JoinByTags(stru, JoinUnsortedBit, " AND ", "json", "name", "age")

func JoinNamesByElements

func JoinNamesByElements(u interface{}, ty JoinType, sep string, eles ...string) string

func JoinTagsByElements

func JoinTagsByElements(u interface{}, ty JoinType, sep string, tagname string, eles ...string) (ret string)

JoinTagsByElements(stru, JoinUnsortedBit, " AND ", "json", "Name", "Age")

func NameTag

func NameTag(u interface{}, field string) string

func NotEmpty

func NotEmpty(d interface{}, errs ...error) bool

NotEmpty check if a value is empty @warn NotEmpty(byte(0)) == false, NotEmpty(byte('0')) == true

NotEmpty(0) == false, NotEmpty(-1) == true, NotEmpty(1) == true

func Slice

func Slice(d interface{}, errs ...error) ([]interface{}, error)

func String

func String(d interface{}, errs ...error) string

String convert into string @warn byte is a built-in alias of uint8, String('A') returns "97"; String(Dbyte('A')) returns "A"

func StringItem

func StringItem(arr []interface{}, i int) string

主要用于 redis.Values

func Tag

func Tag(u interface{}, field string, tagname string) string

Tag Get tag of a struct. e.g. struct { Iwi string `name:"iwi"`, Nation string `name:"nation"`} dtype.Tag(stru, "Iwi", "name")

func Uint

func Uint(d interface{}, errs ...error) (uint, error)

func Uint16

func Uint16(d interface{}, errs ...error) (uint16, error)

func Uint16Item

func Uint16Item(arr []interface{}, i int) uint16

func Uint32

func Uint32(d interface{}, errs ...error) (uint32, error)

func Uint32Item

func Uint32Item(arr []interface{}, i int) uint32

func Uint64

func Uint64(d interface{}, errs ...error) (uint64, error)

func Uint64Item

func Uint64Item(arr []interface{}, i int) uint64

func Uint8

func Uint8(d interface{}, errs ...error) (uint8, error)

func Uint8Item

func Uint8Item(arr []interface{}, i int) uint8

func UintItem

func UintItem(arr []interface{}, i int) uint

func ValueByName

func ValueByName(u interface{}, tag string) (interface{}, error)

func ValueByTag

func ValueByTag(u interface{}, tagname string, tag string) (interface{}, error)

ValueByTag Get value by its tag in a struct

Types

type Dbyte

type Dbyte byte

Dbyte String('A') will returns "97". So you have to use String(Dbyte('A')) to return "A"

type Dtype

type Dtype struct {
	Value interface{}
}

func New

func New(data interface{}) *Dtype

func (*Dtype) Bool

func (p *Dtype) Bool() (bool, error)

func (*Dtype) Bytes

func (p *Dtype) Bytes() []byte

func (*Dtype) DefaultBool

func (p *Dtype) DefaultBool(defaultValue bool) bool

func (*Dtype) DefaultBytes

func (p *Dtype) DefaultBytes(defaultValue []byte) []byte

func (*Dtype) DefaultFloat32

func (p *Dtype) DefaultFloat32(defaultValue float32) float32

func (*Dtype) DefaultFloat64

func (p *Dtype) DefaultFloat64(defaultValue float64) float64

func (*Dtype) DefaultInt

func (p *Dtype) DefaultInt(defaultValue int) int

func (*Dtype) DefaultInt16

func (p *Dtype) DefaultInt16(defaultValue int16) int16

func (*Dtype) DefaultInt32

func (p *Dtype) DefaultInt32(defaultValue int32) int32

func (*Dtype) DefaultInt64

func (p *Dtype) DefaultInt64(defaultValue int64) int64

func (*Dtype) DefaultInt8

func (p *Dtype) DefaultInt8(defaultValue int8) int8

func (*Dtype) DefaultSlice

func (p *Dtype) DefaultSlice(defaultValue []interface{}) []interface{}

func (*Dtype) DefaultString

func (p *Dtype) DefaultString(defaultValue string) string

func (*Dtype) DefaultUint

func (p *Dtype) DefaultUint(defaultValue uint) uint

func (*Dtype) DefaultUint16

func (p *Dtype) DefaultUint16(defaultValue uint16) uint16

func (*Dtype) DefaultUint32

func (p *Dtype) DefaultUint32(defaultValue uint32) uint32

func (*Dtype) DefaultUint64

func (p *Dtype) DefaultUint64(defaultValue uint64) uint64

func (*Dtype) DefaultUint8

func (p *Dtype) DefaultUint8(defaultValue uint8) uint8

func (*Dtype) Float32

func (p *Dtype) Float32() (float32, error)

func (*Dtype) Float64

func (p *Dtype) Float64() (float64, error)

func (*Dtype) Get

func (p *Dtype) Get(keys ...interface{}) (*Dtype, error)

func (*Dtype) Int

func (p *Dtype) Int() (int, error)

func (*Dtype) Int16

func (p *Dtype) Int16() (int16, error)

func (*Dtype) Int32

func (p *Dtype) Int32() (int32, error)

func (*Dtype) Int64

func (p *Dtype) Int64() (int64, error)

func (*Dtype) Int8

func (p *Dtype) Int8() (int8, error)

func (*Dtype) Interface

func (p *Dtype) Interface() interface{}

func (*Dtype) IsEmpty

func (p *Dtype) IsEmpty() bool

func (*Dtype) JsonArray added in v0.0.10

func (p *Dtype) JsonArray() []byte

func (*Dtype) JsonObject added in v0.0.10

func (p *Dtype) JsonObject() []byte

func (*Dtype) NotEmpty

func (p *Dtype) NotEmpty() bool

func (*Dtype) Slice

func (p *Dtype) Slice() ([]interface{}, error)

func (*Dtype) SqlNullFloat64

func (p *Dtype) SqlNullFloat64() sql.NullFloat64

func (*Dtype) SqlNullInt64

func (p *Dtype) SqlNullInt64() sql.NullInt64

func (*Dtype) SqlNullString

func (p *Dtype) SqlNullString() sql.NullString

func (*Dtype) String

func (p *Dtype) String() string

func (*Dtype) Uint

func (p *Dtype) Uint() (uint, error)

func (*Dtype) Uint16

func (p *Dtype) Uint16() (uint16, error)

func (*Dtype) Uint32

func (p *Dtype) Uint32() (uint32, error)

func (*Dtype) Uint64

func (p *Dtype) Uint64() (uint64, error)

func (*Dtype) Uint8

func (p *Dtype) Uint8() (uint8, error)

type JoinType

type JoinType int
const (
	JoinSortedBit JoinType = 1 << 20
)

type Map

type Map struct {
	Value interface{}
}

structs.Map(rsp) 可以将struct 转为 map[string]interface{}

func NewMap

func NewMap(v interface{}) Map

func (Map) Get

func (m Map) Get(key interface{}, keys ...interface{}) (interface{}, error)

Jump to

Keyboard shortcuts

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