saData

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: Apache-2.0 Imports: 21 Imported by: 3

README

interface和基本数据双向转换

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AryStructName

func AryStructName(ary interface{}) (string, error)

func Btos

func Btos(b bool) string

func BytesTos

func BytesTos(b []byte) string

func CamelStr

func CamelStr(s string) string
下划线命名转化为小驼峰命名

xx_yy to xxYy

func Charbasetoi64

func Charbasetoi64(str string) int64

func DataToJson

func DataToJson(m interface{}) (string, error)

func DataToMap

func DataToMap(v interface{}) (map[string]interface{}, error)

func DecodeBase64

func DecodeBase64(s string) string

func EncodeBase64

func EncodeBase64(s string) string

func F32tos

func F32tos(f float32) string

func GetIdByKeys

func GetIdByKeys(args map[string]interface{}, key1 string, key2 string) int64

func GetSuffix

func GetSuffix(s string) string

func I64tocharbase

func I64tocharbase(v int64) string

int和89进制字符转换

func I64tos

func I64tos(i int64) string

func IdsToAry

func IdsToAry(str string) []int64

1,2,3 => []{1,2,3}

func IsEmpty

func IsEmpty(d interface{}) (result bool)

func IsNil

func IsNil(d interface{}) (isNil bool)

func IsNotEmpty

func IsNotEmpty(d interface{}) (result bool)

func IsPhone

func IsPhone(str string) bool

func Itos

func Itos(i int) string

func JsonToMap

func JsonToMap(s string) (ma map[string]interface{}, err error)

func JsonToSlice

func JsonToSlice(s string) (*[]interface{}, error)

func JsonToStruct

func JsonToStruct(s string, m interface{}) error

func LenCheck

func LenCheck(m interface{}, max int) error

func MapToMapStr

func MapToMapStr(ma map[string]interface{}) map[string]string

func MapToQuery

func MapToQuery(ma map[string]interface{}) string

map转query字符串 *

func MapToXml

func MapToXml(m *map[string]string) string

func Md5

func Md5(s string, x bool) string

func Merge

func Merge(target map[string]string, obj map[string]string)

func ModifySysFilePath

func ModifySysFilePath(f string) string

func PageToDic

func PageToDic(page *Page) *map[string]interface{}

func QueryToMap

func QueryToMap(str string) map[string]interface{}

query字符串转map *

func RandomStr

func RandomStr() string

func RemoveDuplicate

func RemoveDuplicate(a interface{}) (ret []interface{})

func Round

func Round(f float64, n int) float64

func Sha256

func Sha256(s string, secret string, x bool) string

func SnakeStr

func SnakeStr(s string) string
下划线命名转为大驼峰命名

XxYy to xx_yy , XxYY to xx_yy

func Stobytes

func Stobytes(s string) []byte

通过内存操作,效率极高,但是有风险。只在数据量很大、效率要求高的场景使用

func Stoi

func Stoi(s string) (int, error)

func Stoi16

func Stoi16(s string) (int16, error)

func Stoi32

func Stoi32(s string) (int32, error)

func Stoi64

func Stoi64(s string) (int64, error)

func Stoui32

func Stoui32(s string) (uint32, error)

func StrLen

func StrLen(s string) int

func StrToTime

func StrToTime(format SaTimeFormat, s string) time.Time

func StructElemValue

func StructElemValue(obj interface{}, k string) reflect.Value

func StructName

func StructName(obj interface{}) (string, error)

func SubIndex

func SubIndex(s string, sub string) int

func SubStr

func SubStr(s string, start int, cnt int) string

func TimeStr

func TimeStr(t time.Time, format SaTimeFormat) string

func ToAry

func ToAry(arr interface{}) ([]interface{}, error)

func ToAryMap

func ToAryMap(arr interface{}) ([]map[string]interface{}, error)

func ToAryStr

func ToAryStr(arr interface{}) ([]string, error)

func ToBool

func ToBool(d interface{}) (bool, error)

func ToBytes

func ToBytes(v interface{}) ([]byte, error)

func ToFloat32

func ToFloat32(d interface{}) (float32, error)

func ToIdAry

func ToIdAry(args map[string]interface{}, key string) []int64

=> []{1,2,3}

func ToIds

func ToIds(ary []int64) string

[]{1,2,3} => 1,2,3

func ToInt

func ToInt(d interface{}) (int, error)

func ToInt32

func ToInt32(d interface{}) (int32, error)

func ToInt64

func ToInt64(d interface{}) (int64, error)

func ToInt8

func ToInt8(d interface{}) (int8, error)

func ToMap

func ToMap(ma interface{}) (map[string]interface{}, error)

func ToMapStr

func ToMapStr(ma interface{}) (map[string]string, error)

func ToPrice

func ToPrice(f float32) float32

func ToStr

func ToStr(d interface{}) (string, error)

func TrimAllSpace

func TrimAllSpace(s string) string

func TrimH5Tags

func TrimH5Tags(src string) (str string)
去除字符串中H5的style、script;

将标签转换为回车,去除连续回车,去除每段开始、结尾空格

func TrimPrefixSpace

func TrimPrefixSpace(s string) string

func TrimSuffixSpace

func TrimSuffixSpace(s string) string

func ValueToMap

func ValueToMap(v reflect.Value) *map[string]interface{}

func WeekIndex

func WeekIndex(t time.Time) int

当年第几周

func XmlToMap

func XmlToMap(s string) (*map[string]string, error)

Types

type ListResult

type ListResult struct {
	ListPtr interface{}
	Cnt     int64
	Offset  int
	Limit   int
}

type Map

type Map map[string]interface{}

type NullInt

type NullInt struct {
	V  int
	Ok bool
}

func IFromMap

func IFromMap(ma map[string]interface{}, key string) NullInt

type NullInt64

type NullInt64 struct {
	V  int64
	Ok bool
}

func I64FromMap

func I64FromMap(ma map[string]interface{}, key string) NullInt64

type NullString

type NullString struct {
	V  string
	Ok bool
}

func StrFromMap

func StrFromMap(ma map[string]interface{}, key string) NullString

type Page

type Page struct {
	Cnt    int64
	Offset int
	Limit  int
}

type SaTimeFormat

type SaTimeFormat int8
const (
	TimeFormat_Default SaTimeFormat = iota //"2006-01-02 15:04:05"

	TimeFormat_hhmm        //"15:04"
	TimeFormat_sys_default //"2006-01-02T15:04:05Z"

	TimeFormat_yymm_Dotted       //"2006.01"
	TimeFormat_yymmdd_Dotted     //"2006.01.02"
	TimeFormat_yymmddhhmm_Dotted //"2006.01.02 15:04"
	TimeFormat_Dotted            //"2006.01.02 15:04:05"

	TimeFormat_yymm_Line       //"2006-01"
	TimeFormat_yymmdd_Line     //"2006-01-02"
	TimeFormat_yymmddhhmm_Line //"2006-01-02 15:04"

	TimeFormat_yymm_Chinese       //"2006年01月"
	TimeFormat_yymmdd_Chinese     //"2006年01月02日"
	TimeFormat_yymmddhhmm_Chinese //"2006年01月02日 15点04分"
	TimeFormat_Chinese            //"2006年01月02日 15时04分05秒"

	TimeFormate_yearStr   //2006
	TimeFormate_monthStr  //200601
	TimeFormate_dayStr    //20060102
	TimeFormate_hourStr   //2006010215
	TimeFormate_minuteStr //200601021504
	TimeFormate_secondStr //20060102150405
)

type StringMap

type StringMap map[string]string

func (StringMap) MarshalXML

func (m StringMap) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*StringMap) UnmarshalXML

func (m *StringMap) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

Jump to

Keyboard shortcuts

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