util

package
v0.0.0-...-3b54ddd Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: Apache-2.0 Imports: 22 Imported by: 6

README

util

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayInArray

func ArrayInArray(min []string, max []string) (has bool, msg string)

func ArrayInMapKey

func ArrayInMapKey(min []string, m map[string]string) (has bool, msg string)

判断一个array每一个元素是不是都在map的key里

func ArrayInMapValue

func ArrayInMapValue(min []string, m map[string]string) (has bool, msg string)

判断一个array每一个原始是不是都在map的value里

func ArrayStringIndex

func ArrayStringIndex(item string, max []string) (index int)

func B2S

func B2S(b []byte) string

b2s converts byte slice to a string without memory allocation. See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .

Note it may break if string and/or slice header will change in the future go versions.

func ChunkJoin

func ChunkJoin(str, sub string, length int) string

func CopyMapString

func CopyMapString(m map[string]string) map[string]string

func DeleteCache

func DeleteCache(key string) bool

func EmptyObject

func EmptyObject(obj interface{})

func EncodeTag

func EncodeTag(tag string) (data map[string]string)

func EqualFloatString

func EqualFloatString(f1, f2 string, point int) bool

两个字串的float值是否相同 point 表示精确到第几个小数点后

func FilterEmpty

func FilterEmpty(m map[string]string)

func FilterMapByFun

func FilterMapByFun(m map[string]string, fun func(s string) string, keys ...string)

func FilterMapString

func FilterMapString(m map[string]string, keys ...string)

func GetCache

func GetCache(key string) (has bool, obj interface{})

func GetElemInterface

func GetElemInterface(v reflect.Value) interface{}

func GetMapKey

func GetMapKey(m map[string]string) (keys []string)

获取map的keys

func GetNotEmptyFields

func GetNotEmptyFields(obj interface{}, inFields ...string) (fields []string)

获取不为空的在inFields中的 结构体中的字段

func HexStrHead2ByteArr

func HexStrHead2ByteArr(hexString string) ([]byte, error)

Hex string, high nibble first

func HexStrHead2String

func HexStrHead2String(hexString string) string

func Interface2Bool

func Interface2Bool(value interface{}, strict bool) (v bool, ok bool)

func Interface2Float

func Interface2Float(value interface{}, strict bool) (v float64, ok bool)

func Interface2Int

func Interface2Int(value interface{}, strict bool) (v int64, ok bool)

func Interface2String

func Interface2String(value interface{}, strict bool) (v string, ok bool)

func Interface2StringWithType

func Interface2StringWithType(value interface{}, strict bool) (v string, ok bool)

func Interface2UInt

func Interface2UInt(value interface{}, strict bool) (v uint64, ok bool)

func IntersectionSlice

func IntersectionSlice(s1 []interface{}, s2 []interface{}) []interface{}

求交集

func IsEmptyValue

func IsEmptyValue(value interface{}) bool

func ItemInArray

func ItemInArray(item string, max []string) (has bool)

判断item是否在数组里 如果数组为空则返回false

func ItemInArrayInt

func ItemInArrayInt(item int, max []int) (has bool)

判断item是否在数组里 如果数组为空则返回false

func Map2UrlValues

func Map2UrlValues(m map[string]string) url.Values

func MapInterface2MapString

func MapInterface2MapString(m map[string]interface{}) map[string]string

func MapListToObjList

func MapListToObjList(obj interface{}, mappers []map[string]interface{}, useTag string) (errInfo string)

func MapStringToObj

func MapStringToObj(obj interface{}, mapper map[string]string, useTag string) (fields []string, errInfo string)

func MapToObj

func MapToObj(obj interface{}, mapper map[string]interface{}, useTag string) (fields []string, errInfo string)

func ObjListToMapList

func ObjListToMapList(obj interface{}, useTag string) (mappers []map[string]interface{})

根据map的key=>value设置Obj的field=>fieldValue 如果传了useTag,那么就会根据obj的Tag的useTag的值获取mapValue并填充到field上, 返回设置成功的Fields列表字段

func ObjToMap

func ObjToMap(obj interface{}, useTag string) map[string]interface{}

func PackRsaPrivateKey

func PackRsaPrivateKey(s string) string

将一行的秘钥字符串转换为----BEGIN...多行的格式

func PackRsaPublicKey

func PackRsaPublicKey(s string) string

将一行的公钥字符串转换为----BEGIN...多行的格式

func Rand

func Rand(min int, max int) int

随机生成int型, 并发下++

func ReverseMap

func ReverseMap(ma map[string]string) (data map[string]string)

将map[string'key']string'value' 转换为map[value]key

func S2B

func S2B(s string) []byte

s2b converts string to a byte slice without memory allocation.

Note it may break if string and/or slice header will change in the future go versions.

func SaveFormFile

func SaveFormFile(root string, mFile multipart.File, fHeader *multipart.FileHeader) (hashCode, filePath string, err error)

保存上传文件

func SetCache

func SetCache(key string, obj interface{}, exp time.Duration)

func SheXing2TuoFeng

func SheXing2TuoFeng(src []byte) (out []byte)

func SortMap

func SortMap(m map[string]string) (key []string, value []string)

func TuoFeng2SheXing

func TuoFeng2SheXing(src []byte) (out []byte)

func UnDuplicatesSlice

func UnDuplicatesSlice(is *[]interface{})

去重

func VersionCompareBigger

func VersionCompareBigger(big, small string) bool

func WalkDir

func WalkDir(dirPth string, suffixs []string) (files []string, err error)

返回所有遍历的文件路径 dirPth suffixs: 不包含.的文件后缀

Types

type Data

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

type FieldTagMapper

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

func GetTagMapperFromPool

func GetTagMapperFromPool(i interface{}) FieldTagMapper

func (*FieldTagMapper) GetFieldMapByTagName

func (p *FieldTagMapper) GetFieldMapByTagName(tag string) (data map[string]string)

type FieldsUtil

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

完整版的字段判断工具

func NewFieldsUtil

func NewFieldsUtil(obj interface{}) *FieldsUtil

func (*FieldsUtil) Exclude

func (p *FieldsUtil) Exclude(fields ...string) *FieldsUtil

func (*FieldsUtil) Fields

func (p *FieldsUtil) Fields() []string

func (*FieldsUtil) Filter

func (p *FieldsUtil) Filter(fields ...string) *FieldsUtil

func (*FieldsUtil) GetNotEmptyFields

func (p *FieldsUtil) GetNotEmptyFields() *FieldsUtil

func (*FieldsUtil) Must

func (p *FieldsUtil) Must(fields ...string) *FieldsUtil

type Mail

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

func NewMail

func NewMail(from, pass, smtpHostP string) *Mail

func (*Mail) Send

func (p *Mail) Send(subject, body string, to []string) error

type OrderKV

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

func ParseOrderKV

func ParseOrderKV(m map[string]string) OrderKV

func (*OrderKV) Add

func (p *OrderKV) Add(key, value string)

func (*OrderKV) Encode

func (p *OrderKV) Encode() []byte

See url.Values.Encode

func (*OrderKV) EncodePhp

func (p *OrderKV) EncodePhp() []byte

func (*OrderKV) EncodeString

func (p *OrderKV) EncodeString() string

func (*OrderKV) EncodeStringWithoutEscape

func (p *OrderKV) EncodeStringWithoutEscape() string

func (*OrderKV) Keys

func (p *OrderKV) Keys() []string

func (*OrderKV) Map

func (p *OrderKV) Map() map[string]string

func (*OrderKV) MapMulti

func (p *OrderKV) MapMulti() map[string][]string

func (*OrderKV) Set

func (p *OrderKV) Set(key, value string)

func (*OrderKV) Sort

func (p *OrderKV) Sort()

func (OrderKV) String

func (p OrderKV) String() string

func (*OrderKV) UrlValue

func (p *OrderKV) UrlValue() url.Values

func (*OrderKV) Values

func (p *OrderKV) Values() []string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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