Documentation ¶
Overview ¶
* @Author: kamalyes 501893067@qq.com * @Date: 2024-11-09 01:15:55 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-09 01:05:55 * @FilePath: \go-toolbox\pkg\convert\bytes.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2024-11-09 01:00:55 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-09 01:00:55 * @FilePath: \go-toolbox\pkg\convert\ip.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2024-08-03 21:32:26 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-13 09:06:59 * @FilePath: \go-toolbox\pkg\convert\must.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2024-11-09 01:15:55 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-09 12:22:59 * @FilePath: \go-toolbox\pkg\convert\radix.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
Index ¶
- func B2S(b []byte) string
- func B64Decode(s string) ([]byte, error)
- func B64Encode(data interface{}) (string, error)
- func B64ToByte(imageBase64 string) ([]byte, error)
- func B64UrlDecode(s string) ([]byte, error)
- func B64UrlEncode(data interface{}) (string, error)
- func ByteToBinStr(b byte) string
- func BytesToBCC(data []byte) byte
- func BytesToBinStr(bs []byte) string
- func BytesToBinStrWithSplit(bs []byte, split string) string
- func BytesToHex(data []byte) string
- func DecToBin(n uint64) string
- func DecToHex(n uint64) string
- func Float64ToInt[T types.Numerical](value float64, mode RoundMode) (T, error)
- func HexToBCC(hexStr string) (string, error)
- func HexToBin(h string) (string, error)
- func HexToBytes(hexStr string) ([]byte, error)
- func HexToDec(h string) (uint64, error)
- func IP2Long(ip net.IP) (uint, error)
- func Long2IP(i uint) (net.IP, error)
- func MustBool[T any](v T) bool
- func MustIntT[T types.Numerical](value any, mode *RoundMode) (T, error)
- func MustJSON(v interface{}) ([]byte, error)
- func MustJSONIndent(v interface{}) ([]byte, error)
- func MustString[T any](v T, timeLayout ...string) string
- func NumberSliceToStringSlice[T types.Numerical](numbers []T) []string
- func ParseFloat[T types.Float](v string, value *T) error
- func S2B(s string) []byte
- func SliceByteToString(b []byte) string
- func StringSliceToNumberSlice[T types.Numerical](strs []string, mode *RoundMode) ([]T, error)
- func StringToSliceByte(s string) []byte
- type RoundMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func B2S ¶
B2S converts byte slice to string without a memory allocation. Slower: unsafe.String(unsafe.SliceData(b), len(b)) strings.Clone(): unsafe.String(&b[0], len(b))
func B64ToByte ¶ added in v0.11.5
B64ToByte 将 Base64 字符串解码为字节切片 参数:imageBase64 - 要解码的 Base64 字符串 返回:解码后的字节切片和可能的错误
func B64UrlEncode ¶
B64UrlEncode Base64 URL 安全编码
func BytesToBinStrWithSplit ¶
BytesToBinStrWithSplit 将字节数组转换为二进制字符串,并添加分隔符
func Float64ToInt ¶ added in v0.11.7
Float64ToInt 将浮点数转换为整数类型,并进行取整
func HexToBytes ¶
HexToBytes 将十六进制字符串转换为字节数组。 如果十六进制字符串的长度为奇数或转换失败,则返回错误。
func MustJSONIndent ¶
MustJSONIndent 转 json 返回 []byte
func NumberSliceToStringSlice ¶ added in v0.11.7
NumberSliceToStringSlice Number切片转String
func ParseFloat ¶ added in v0.11.7
ParseFloat 尝试将字符串解析为指定类型的浮点数
func S2B ¶
S2B converts string to byte slice without a memory allocation. Ref: https://github.com/golang/go/issues/53003#issuecomment-1140276077
func SliceByteToString ¶ added in v0.11.5
SliceByteToString 将字节切片转换为字符串
func StringSliceToNumberSlice ¶ added in v0.11.7
StringSliceToNumberSlice 将字符串切片转换为数字切片
func StringToSliceByte ¶ added in v0.11.5
StringToSliceByte 将字符串转换为字节切片