tools

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JsonConfig = jsoniter.Config{
	EscapeHTML:    true,
	CaseSensitive: true,
}.Froze()

Functions

func Any2json

func Any2json(data any, path ...string) gjson.Result

Any2json 转成json

func Any2struct

func Any2struct(data any, stru any) error

Any2struct 转成struct

func Base64Decode

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

Base64Decode base64解密

func Base64Encode

func Base64Encode[T string | []byte](val T) string

Base64Encode base64 加密

func BytesToString

func BytesToString(b []byte) string

BytesToString 字节串转字符串

func CharSet added in v0.0.2

func CharSet(content []byte, contentType string) ([]byte, string, error)

CharSet 网页解码,并返回 编码

func CopyWitchContext

func CopyWitchContext(ctx context.Context, writer io.Writer, reader io.Reader) (err error)

func Decode

func Decode[T string | []byte](txt T, code string) T

Decode 转码

func DecodeRead

func DecodeRead(txt io.Reader, code string) io.Reader

DecodeRead 转码

func GetContentTypeWithBytes

func GetContentTypeWithBytes(content []byte) string

func GetServerName

func GetServerName(addr string) string

func ImgDiffer

func ImgDiffer(c, c2 []byte) (float64, error)

func Merge

func Merge(c1 any, c2 any)

Merge 合并两个结构体 *ci c2

func ParseHost

func ParseHost(host string) (net.IP, int)

func ParseIp

func ParseIp(ip net.IP) int

func SetUnExportedField

func SetUnExportedField[T any](source T, fieldName string, newFieldVal any) T

func Signal

func Signal(preCtx context.Context, fun func())

func SplitHostPort

func SplitHostPort(address string) (string, int, error)

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes 字符串转字节串

func WrapError

func WrapError(err error, val ...any) error

func ZipDecode

func ZipDecode(ctx context.Context, r *bytes.Buffer, encoding string) (*bytes.Buffer, error)

ZipDecode 压缩解码

Types

This section is empty.

Jump to

Keyboard shortcuts

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