utility

package
v0.0.0-...-e1367df Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//日期时间格式
	FORMATDATETIME = "2006-01-02 15:04:05"

	//日期格式
	FORMATDATE = "2006-01-02"

	//数据库时间格式
	FORMATSQLTIME   = "2006-01-02 15:04:05.999999999Z07:00"
	FORMATMSSQLTIME = "2006-01-02T15:04:05Z07:00"

	//日志时间格式
	FORMATLOGTIME = "1月2日 15:04:05"
)

Variables

View Source
var TIMEZONE *time.Location

Functions

func BytesToString

func BytesToString(b []byte) string

BytesToString converts byte slice to string without a memory allocation.

func ConvToFloat64ByKey

func ConvToFloat64ByKey(data map[string]interface{}, keys ...string)

根据key转换map对象string值为float64值

func ConvToInt32ByKey

func ConvToInt32ByKey(data map[string]interface{}, keys ...string)

根据key转换map对象string值为int值

func ConvToInt64ByKey

func ConvToInt64ByKey(data map[string]interface{}, keys ...string)

根据key转换map对象string值为int64值

func ConvToTimeByKey

func ConvToTimeByKey(data map[string]interface{}, local *time.Location, keys ...string)

根据key转换map对象string值为time.Time值

func FilterMapFieldNull

func FilterMapFieldNull(sdata map[string]interface{}) (ddata map[string]interface{})

过滤map对象的nil值属性

func GetHashcode

func GetHashcode(v interface{}) int32

计算hashcode,目前只支持int,string等基础类型

func GetPathValid

func GetPathValid(v ...string) (string, error)

判断有效的配置文件路径并返回

func GetStringCode

func GetStringCode(str string) int32

func StrToTime

func StrToTime(str string, local *time.Location) (time.Time, error)

字符串转换为时间

func StringToBytes

func StringToBytes(s string) (b []byte)

StringToBytes converts string to byte slice without a memory allocation.

func TransfMap2Struct

func TransfMap2Struct(source map[string]interface{}, inStructPtr interface{}) error

Map数据转换为Struct结构(原始变量类型)

func TransfMap2StructNulltype

func TransfMap2StructNulltype(source map[string]interface{}, inStructPtr interface{}) error

Map数据转换为Struct结构(null变量类型,包:gopkg.in/guregu/null.v3)

func TransfStruct2Map

func TransfStruct2Map(obj interface{}, keys []string) map[string]interface{}

Struct数据转换为Map结构

Types

type MapItem

type MapItem struct {
	Key string
	Val interface{}
}

func MapSortByKey

func MapSortByKey(list map[string]interface{}, orderBy string) []MapItem

type MapSorter

type MapSorter struct {
	OrderBy string
	Items   []MapItem
}

func NewMapSorter

func NewMapSorter(m map[string]interface{}, o string) MapSorter

func (MapSorter) Len

func (ms MapSorter) Len() int

func (MapSorter) Less

func (ms MapSorter) Less(i, j int) bool

按键排序

func (MapSorter) Swap

func (ms MapSorter) Swap(i, j int)

Jump to

Keyboard shortcuts

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