dashconv

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package dashconv

类型转换工具

Type conversion tool

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteToStr

func ByteToStr(b []byte) string

ByteToStr @Editor robotyang at 2023

ByteToStr 字节 转 字符串

func ByteToStrByUnsafe

func ByteToStrByUnsafe(b []byte) string

ByteToStrByUnsafe @Editor robotyang at 2023

ByteToStrByUnsafe 字节 转 字符串

func GbkToUtf8

func GbkToUtf8(s []byte) ([]byte, error)

GbkToUtf8 @Editor robotyang at 2023

GbkToUtf8 转换 GBK字符串 为 UTF8字符串

func ObjToMap

func ObjToMap(data any) (maps any, err error)

ObjToMap @Editor robotyang at 2023

ObjToMap 转换 数据为Map结构

@Param data:支持 struct、map、slice 以及它们的指针类型

@Return maps:可为 map[string]any、[]any

func StrToByte

func StrToByte(s string) []byte

StrToByte @Editor robotyang at 2023

StrToByte 字符串 转 字节

func StrToByteByReflect deprecated

func StrToByteByReflect(s string) []byte

Deprecated: StrToByteByReflect @Editor robotyang at 2023(运行时可能不可靠,仅供学习)

StrToByteByReflect @Editor robotyang at 2023

StrToByteByReflect 将字符串转换为字节片而不分配内存。注意,如果字符串和/或切片头在未来的go版本中改变,它可能会中断。

# StrToByteByReflect converts string to a byte slice without memory allocation. Note it may break if string and/or slice header will change in the future go versions.

func StrToByteByUnsafe

func StrToByteByUnsafe(s string) []byte

StrToByteByUnsafe @Editor robotyang at 2023

StrToByteByUnsafe 字符串 转 字节

func TransEncoding

func TransEncoding(src string, srcCode string, dstCode string) string

TransEncoding @Editor robotyang at 2023

TransEncoding 转换 字符串 编码类型

@Param src:原字符串

@Param srcCode:原字符串 编码类型,如 "gbk"、"utf-8"

@Param dstCode:目标字符串 编码类型,如 "gbk"、"utf-8"

func Utf8ToGbk

func Utf8ToGbk(s []byte) ([]byte, error)

Utf8ToGbk @Editor robotyang at 2023

Utf8ToGbk 转换 UTF8字符串 为 GBK字符串

func WeakMapToStructWithTag

func WeakMapToStructWithTag(inMap, outStruct any, tagName string) error

WeakMapToStructWithTag @Editor robotyang at 2023

WeakMapToStructWithTag 解析map到结构体(自定义tag 作为 key)

@Param inMap:输入的map

@Param outStruct:接收的结构体

@Param tagName:结构体的关联tag名

Types

This section is empty.

Jump to

Keyboard shortcuts

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