xlfbUtilConvert

package
v0.0.0-...-b5383aa Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(src string) (string, error)

Base64Decode decodes a base64 string

func Base64Encode

func Base64Encode(src string) string

Base64Encode encodes a string to base64

func Base64ToBytes

func Base64ToBytes(s string) ([]byte, error)

Base64ToBytes converts a base64 string to a byte array

func BaseToInt

func BaseToInt(s string, base int) (int64, error)

BaseToInt converts a string representation in the specified base to an integer

func BaseToUint

func BaseToUint(s string, base int) (uint64, error)

BaseToUint converts a string representation in the specified base to an unsigned integer

func BinaryToDecimal

func BinaryToDecimal(s string) (int64, error)

BinaryToDecimal converts a binary string to a decimal integer

func BytesToBase64

func BytesToBase64(bys []byte) string

BytesToBase64 converts a byte array to a base64 string

func BytesToFloat32

func BytesToFloat32(bys []byte) float32

BytesToFloat32 converts a byte array to float32

func BytesToFloat64

func BytesToFloat64(bys []byte) float64

BytesToFloat64 converts a byte array to float64

func BytesToHexString

func BytesToHexString(bys []byte) string

BytesToHexString converts a byte array to a hexadecimal string

func BytesToInt

func BytesToInt(bys []byte) int

func BytesToInt32

func BytesToInt32(bys []byte, length int) int32

func BytesToInt64

func BytesToInt64(bys []byte) int64

func BytesToUint

func BytesToUint(bys []byte) uint

BytesToUint converts a byte array to uint

func BytesToUint32

func BytesToUint32(bys []byte) uint32

BytesToUint32 converts a byte array to uint32

func BytesToUint64

func BytesToUint64(bys []byte) uint64

BytesToUint64 converts a byte array to uint64

func CamelToUnderscore

func CamelToUnderscore(src string) string

func CompactJSON

func CompactJSON(jsonStr string) (string, error)

CompactJSON removes whitespace from a JSON string

func DecimalToBinary

func DecimalToBinary(n int64) string

DecimalToBinary converts a decimal integer to a binary string

func DecimalToHex

func DecimalToHex(n int64) string

DecimalToHex converts a decimal integer to a hexadecimal string

func Float32ToBytes

func Float32ToBytes(f float32) []byte

Float32ToBytes converts a float32 to a byte array

func Float64ToBytes

func Float64ToBytes(f float64) []byte

Float64ToBytes converts a float64 to a byte array

func FromJSON

func FromJSON(jsonStr string, v interface{}) error

FromJSON converts a JSON string to a Go value

func GetJSONField

func GetJSONField(jsonStr string, fieldPath string) (interface{}, error)

GetJSONField extracts a specific field from a JSON string

func HexStringToBytes

func HexStringToBytes(s string) ([]byte, error)

HexStringToBytes converts a hexadecimal string to a byte array

func HexToDecimal

func HexToDecimal(s string) (int64, error)

HexToDecimal converts a hexadecimal string to a decimal integer

func IntSliceToString

func IntSliceToString(src []int, sep string) string

func IntToBase

func IntToBase(n int64, base int) string

IntToBase converts an integer to a string representation in the specified base

func IntToBitBytes

func IntToBitBytes(n int, length int) []byte

func IsValidJSON

func IsValidJSON(jsonStr string) bool

IsValidJSON checks if a string is valid JSON

func JSONToMap

func JSONToMap(jsonStr string) (map[string]interface{}, error)

JSONToMap converts a JSON string to a map[string]interface{}

func JSONToSlice

func JSONToSlice(jsonStr string) ([]interface{}, error)

JSONToSlice converts a JSON string to a []interface{}

func MacSplitWithColon

func MacSplitWithColon(src string) string

func MacSplitWithDash

func MacSplitWithDash(src string) string

func MapKeys

func MapKeys[K comparable, V any](m map[K]V) []K

MapKeys returns all keys from a map as a slice

func MapToSlice

func MapToSlice[K comparable, V any](m map[K]V) []V

MapToSlice converts a map to a slice

func MapValues

func MapValues[K comparable, V any](m map[K]V) []V

MapValues returns all values from a map as a slice

func PrettyPrintJSON

func PrettyPrintJSON(jsonStr string) (string, error)

PrettyPrintJSON formats a JSON string with proper indentation

func SetJSONField

func SetJSONField(jsonStr string, fieldPath string, value interface{}) (string, error)

SetJSONField sets a specific field in a JSON string

func SliceToMap

func SliceToMap[T any](slice []T, keyFunc func(T) string) map[string]T

SliceToMap converts a slice to a map using the provided key function keyFunc should return a string key for each element in the slice

func SliceToString

func SliceToString(src []interface{}, sep string) string

func SortDecimals

func SortDecimals(decimals []decimal.Decimal, asc bool)

SortDecimals sorts a slice of decimal.Decimal in ascending order. If asc is true, the slice will be sorted in ascending order; otherwise, it will be sorted in descending order. asc mode the first element will be the smallest value. desc mode the first element will be the largest value.

func SortFloat64s

func SortFloat64s(floats []float64, asc bool)

SortFloat64s sorts a slice of float64 values in ascending or descending order

func SortInts

func SortInts(ints []int, asc bool)

SortInts sorts a slice of integers in ascending or descending order

func SortStrings

func SortStrings(strings []string, asc bool)

SortStrings sorts a slice of strings in ascending or descending order

func SplitClean

func SplitClean(src string) []string

func SplitDefault

func SplitDefault(src string) []string

func SplitTrimSpace

func SplitTrimSpace(src string) []string

func StringToMap

func StringToMap(src string, kvSep string, pairSep string) map[string]string

StringToMap converts a string to a map using the specified key-value separator and pair separator Example: "key1=value1,key2=value2" with kvSep="=" and pairSep="," returns {"key1":"value1", "key2":"value2"}

func StringToSlice

func StringToSlice(src string, sep string) []string

StringToSlice converts a string to a slice using the specified separator

func ToBool

func ToBool(src interface{}) bool

ToBool converts various types to bool

func ToFloat64

func ToFloat64(src interface{}) float64

ToFloat64 转float64

func ToInt

func ToInt(src interface{}) int

ToInt 转int

func ToInt64

func ToInt64(src interface{}) int64

ToInt64 转int64

func ToJSON

func ToJSON(v interface{}) (string, error)

ToJSON converts a Go value to a JSON string

func ToPrettyJSON

func ToPrettyJSON(v interface{}) (string, error)

ToPrettyJSON converts a Go value to a pretty-printed JSON string

func ToString

func ToString(src interface{}) string

ToString 转字符

func ToUint

func ToUint(src interface{}) uint

ToUint converts various types to uint

func ToUint64

func ToUint64(src interface{}) uint64

ToUint64 converts various types to uint64

func UintToBase

func UintToBase(n uint64, base int) string

UintToBase converts an unsigned integer to a string representation in the specified base

func UnderscoreToCamel

func UnderscoreToCamel(src string) string

UnderscoreToCamel converts snake_case to camelCase

func UrlDecode

func UrlDecode(src string) (string, error)

UrlDecode decodes a URL-encoded string

func UrlEncode

func UrlEncode(src string) string

UrlEncode encodes a string for URL

Types

This section is empty.

Source Files

  • bytes.go
  • json.go
  • numeric.go
  • sort.go
  • strings.go

Jump to

Keyboard shortcuts

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