util

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: Apache-2.0 Imports: 16 Imported by: 1

README

util

for golang common util

Documentation

Index

Constants

View Source
const (
	// todo 设置最大数据条数,目前暂定100w
	MaxPageSize = 1000000 //最大的查询页数
)

Variables

FastJson

Functions

func FindNumsInString added in v0.0.4

func FindNumsInString(s string) []string

找出字符串中所有数字, 如果没有匹配的,则返回nil

func GetMapKeys

func GetMapKeys(data map[string]interface{}) []string

get map keys

func GetMapKeys2

func GetMapKeys2(data map[string]string) []string

get map[string]string keys

func GetStructFields

func GetStructFields(obj interface{}) []string

func GetStructJsonTags

func GetStructJsonTags(obj interface{}) []string

func HmacMD5

func HmacMD5(input, key string) string

hmac-md5 input with key

func HmacSha1

func HmacSha1(input, key string) string

hmac-sha1 input with key

func InitPageAndPageSize

func InitPageAndPageSize(page string, pageSize string) (offset int, limit int)

初始化page和pageSize, 默认page为0, pageSize=10, 返回默认为字符串,方便之后查询拼接字符串

func MapInterfaceToString added in v0.0.4

func MapInterfaceToString(data map[string]interface{}) map[string]string

convert map[string]interface{} to map[string]string

func MapStringToInterface added in v0.0.4

func MapStringToInterface(data map[string]string) map[string]interface{}

convert map[string]string to map[string]interface{}

func NewUUID

func NewUUID() (string, error)

func OnlyCols

func OnlyCols(cols []string, data map[string]string)

过滤字段,map中只保留需要的键值对

func OnlyColumns

func OnlyColumns(cols []string, data map[string]interface{}) map[string]interface{}

过滤字段,返回只包含了cols的map

func RandomNumber

func RandomNumber(length int) string

RandomNumber generate random number string, not 0 start with pseudo-random

func RandomStr

func RandomStr(length int) string

RandomStr generate random string with pseudo-random,maybe 0 begin

func SliceAndTrim

func SliceAndTrim(str string, sep string) []string

slice and trim white space

func StructJsonTagToMap

func StructJsonTagToMap(obj interface{}) map[string]interface{}

obj 不能为指针

func StructToMap

func StructToMap(obj interface{}) map[string]interface{}

func ToJsonString

func ToJsonString(data interface{}) string

return json string

func TrueRandomNumber

func TrueRandomNumber(length int) string

TrueRandomNumber generate random number string, not 0 start with true random

func TrueRandomStr

func TrueRandomStr(length int) string

TrueRandomStr generate random string with true random,maybe 0 begin

func TwoDecimalPlaces added in v0.0.4

func TwoDecimalPlaces(value float64) float64

截取2位小数,四舍五不入。 这里通过 ✖️100取math.Floor再➗100方式实现的两位小数

Types

This section is empty.

Jump to

Keyboard shortcuts

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