helper

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 5 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// FasterJson 更快的配置,浮点数仅能保留6位小数, 且不能序列化HTML
	FasterJson          = jsoniter.ConfigFastest
	FasterJsonMarshal   = FasterJson.Marshal
	FasterJsonUnmarshal = FasterJson.Unmarshal
	// DefaultJson 默认配置
	DefaultJson       = FasterJson
	JsonMarshal       = DefaultJson.Marshal
	JsonUnmarshal     = DefaultJson.Unmarshal
	JsonMarshalIndent = DefaultJson.MarshalIndent
	JsonNewDecoder    = DefaultJson.NewDecoder
	JsonNewEncoder    = DefaultJson.NewEncoder
)
View Source
var (
	F           = CombineStrings
	StringsJoin = CombineStrings
)

Functions

func B2S

func B2S(b []byte) string

B2S 将[]byte转换为字符串,(就地修改)零内存分配

func Base64Decode

func Base64Decode(data string) ([]byte, error)

Base64Decode base64解码

@param	data	string	base64字符串

func Base64Encode

func Base64Encode(data []byte) string

Base64Encode base64编码

@param	data	[]byte	字节流
@return	string base64字符串

func CombineStrings

func CombineStrings(elems ...string) string

CombineStrings 合并字符串, 实现等同于strings.Join(),只是少了判断分隔符

func Has

func Has[T comparable](s []T, x T) bool

Has 查找序列s内是否存在元素x

@param	s	[]T	查找序列
@param	x	T	特定元素
@return	bool true if s contains x, false otherwise

func HexBeautify

func HexBeautify(src []byte) string

HexBeautify 格式化显示十六进制

func IsEqual

func IsEqual[T comparable](a, b []T) bool

IsEqual 判断2个切片是否相等

@return	true if is equal

func MapToString

func MapToString(object map[string]any) string

MapToString 将字典转换成字符串显示

func Reverse

func Reverse[T any](s *[]T)

Reverse 数组倒序, 就地修改

@param	s	*[]T	需要倒序的序列

func S2B

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

S2B 将字符串转换为[]byte,(就地修改)零内存分配

func SetJsonEngine

func SetJsonEngine(api jsoniter.API)

SetJsonEngine 修改默认的JSON配置

func WordCapitalize

func WordCapitalize(word string) string

WordCapitalize 单词首字母大写

@param	word	string	单词
@return	string 首字母大写的单词

Types

This section is empty.

Jump to

Keyboard shortcuts

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