strUtil

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bcd2Number

func Bcd2Number(bcd []byte) string

func Bytes2String

func Bytes2String(b []byte) string

Bytes2String 直接转换底层指针,两者指向的相同的内存,改一个另外一个也会变。 效率是string([]byte{})的百倍以上,且转换量越大效率优势越明显。

func CompareVersion

func CompareVersion(src, dst string) int

CompareVersion 版本比较, src > dst 返回 1 src = dst 返回 0 src < dst 返回 -1

func Constains

func Constains(str string, sub string) bool

func Decoder2Json

func Decoder2Json(str string, v interface{}) error

长字符串通过decode的方法进行解析(包括数组)

func Empty

func Empty(str string) bool

func FillZero

func FillZero(sl []string, i int) []string

func FmtSlice

func FmtSlice(f, space string, args ...interface{}) string

func FmtSliceByDefault

func FmtSliceByDefault(args ...interface{}) string

func GetRandomString

func GetRandomString(l int) string

GetRandomString 获取指定长度的随机字符串

func Hash

func Hash(v interface{}) (uint64, error)

Hash returns the xxhash of an arbitrary value or struct. NOT SUITABLE FOR CRYTOGRAPHIC HASHING.

func Hex2Byte

func Hex2Byte(str string) []byte

func Hex2Str

func Hex2Str(b []byte) string

func IsArray

func IsArray(data []byte) (bool, error)

IsArray 判断当前字符串是数组还是对象

func Md5

func Md5(str string) string

func MustHash

func MustHash(v interface{}) uint64

MustHash returns the xxhash of an arbitrary value or struct. Returns 0 on error. NOT SUITABLE FOR CRYTOGRAPHIC HASHING.

func Number2bcd

func Number2bcd(number string) []byte

func ObjByAnchor

func ObjByAnchor(str, anchor string) interface{}

func Parse

func Parse(str string, v interface{}) error

func ParseByBytes

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

func ParseFromYaml

func ParseFromYaml(str string, v interface{}) error

func RandStringBytesMaskImpr

func RandStringBytesMaskImpr(n int) []byte

RandStringBytesMaskImpr 生成指定长度的随机字符串

func RandomString

func RandomString(l int) string

* l <= 9

func String2Bytes

func String2Bytes(s string) []byte

String2Bytes 直接转换底层指针,两者指向的相同的内存,改一个另外一个也会变。 效率是string([]byte{})的百倍以上,且转换量越大效率优势越明显。 转换之后若没做其他操作直接改变里面的字符,则程序会崩溃。 如 b:=String2bytes("xxx"); b[1]='d'; 程序将panic。

func ToAscii

func ToAscii(str string) string

func ToBytes

func ToBytes(obj interface{}) []byte

func ToJsonStr

func ToJsonStr(obj interface{}) string

ToJsonStr 将对象转为json字符串

func ToStr

func ToStr(value interface{}) string

ToStr 获取变量的字符串值 浮点型 3.0将会转换成字符串3, "3" 非数值或字符类型的变量将会被转换成JSON格式字符串

func TrimSpace

func TrimSpace(str string) string

去掉字符串头尾的不可见字符(空格,换行,制表) \p{C}来匹配所有的控制字符(包括不可见字符)

func UnsafeEqual

func UnsafeEqual(a string, b []byte) bool

UnsafeEqual 比较字符串与字节数组中的内容是否一致

Types

This section is empty.

Jump to

Keyboard shortcuts

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