utils

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

README

hdutils

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(b []byte) string

BytesToString converts byte slice to text without memory allocation.

func CsvToNumbers added in v0.2.0

func CsvToNumbers[T Numeric](s string) ([]T, error)

CsvToNumbers converts a comma-separated string to a slice of the specified numeric type. Returns the slice and any conversion error encountered.

func NumbersToCsv added in v0.2.0

func NumbersToCsv[T Numeric](numbers []T) string

NumbersToCsv 将int64 slice转换成用逗号分隔的字符串: 1,2,3

func NumbersToStrings added in v0.2.0

func NumbersToStrings[T Numeric](numbers []T) []string

NumbersToStrings converts a slice of numeric types to a slice of strings.

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes converts text to byte slice without memory allocation.

func StringsToNumbers added in v0.2.0

func StringsToNumbers[T Numeric](strSlice []string) ([]T, error)

StringsToNumbers converts a string slice to numeric slice with error handling

func ToBytes added in v0.2.0

func ToBytes(value any) ([]byte, error)

func ToSlice added in v0.2.0

func ToSlice(data any) []any

ToSlice 将传过来的数据转换成[]any

func ToString added in v0.2.0

func ToString(value any) (string, error)

ToString 尝试将值转换成字符串

Types

type Numeric added in v0.2.0

type Numeric interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
		~float32 | ~float64
}

Directories

Path Synopsis
ast module
cmp module
convert module
encoding module
hash module
json module
paginator module
panic module
reflect module
text module
time module

Jump to

Keyboard shortcuts

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