utils

package
v0.0.0-...-98a29f8 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Reset  = "\033[0m"
	Red    = "\033[31m"
	Green  = "\033[32m"
	Yellow = "\033[33m"
)

定义一些ANSI转义码的颜色常量

Variables

View Source
var DEBUG = true
View Source
var (
	Seed = uint32(1)
)

Functions

func Decode

func Decode(data []byte) map[string]interface{}

func Decoder

func Decoder(data []byte, v interface{})

func DeleteArray

func DeleteArray(array []uint32, index int) []uint32

func DeleteStringArray

func DeleteStringArray(array []string, index int) []string

func DirSizeB

func DirSizeB(path string) int64

DirSizeB DirSizeMB getFileSize get file size by path(B)

func Encode

func Encode(data interface{}) []byte

func Encoder

func Encoder(data interface{}) []byte

func ExecTime

func ExecTime(fn func()) float64

func ExecTimeWithError

func ExecTimeWithError(fn func() error) (float64, error)

func FindByExp

func FindByExp(str interface{}, exp_str string) bool

func GenerateRandomString

func GenerateRandomString(length int) (string, error)

GenerateRandomString 生成固定长度的随机字符串 length 是期望的字符串长度 注意:由于我们使用了hex编码,实际生成的随机字节长度需要是目标字符串长度的一半(向上取整)

func Map2String

func Map2String(m map[string]interface{}, has_key bool) string

func Map2Strings

func Map2Strings(m map[string]interface{}, has_key bool) []string

func MergeMap

func MergeMap(elem1, elem2 map[string]interface{}) map[string]interface{}

合并两个元素

func Murmur3

func Murmur3(key []byte) (hash uint32)

func Now

func Now() string

func Obj2Map

func Obj2Map(obj any) map[string]interface{}

func Printc

func Printc(format string, color string, a ...interface{})

func Printf

func Printf(format string, a ...interface{})

func Println

func Println(a ...interface{})

func QuickSortAsc

func QuickSortAsc(arr []int, start, end int, cmp func(int, int))

QuickSortAsc 快速排序

func ReleaseAssets

func ReleaseAssets(file fs.File, out string)

func RemoveDuplicates

func RemoveDuplicates(input []string) []string

RemoveDuplicates 去除字符串slice中的重复项,返回不含重复项的新slice 参数input: 需要去重的字符串slice 返回值: 去除重复项后的字符串slice

func RemoveHTMLTags

func RemoveHTMLTags(s string) string

RemoveHTMLTags 去除HTML标签的函数

func RemovePunctuation

func RemovePunctuation(str string) string

RemovePunctuation 移除所有的标点符号

func RemoveSpace

func RemoveSpace(str string) string

RemoveSpace 移除所有的空格

func Sha1Hash

func Sha1Hash(text string) string

将字符串转换为SHA-1哈希值

func StringToInt

func StringToInt(value string) uint32

StringToInt 字符串转整数

func UUID

func UUID() string

func Uint32Comparator

func Uint32Comparator(a, b interface{}) int

func Uint32ToBytes

func Uint32ToBytes(i uint32) []byte

func Uint64ToBytes

func Uint64ToBytes(n uint64) []byte

Types

This section is empty.

Jump to

Keyboard shortcuts

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