Documentation
¶
Overview ¶
Package utils provides utility functions for common operations.
Index ¶
- func AesDecryptCBC(encrypted []byte, key []byte) (decrypted []byte)
- func AesDecryptCBCIV(encrypted []byte, key, iv []byte) (decrypted []byte)
- func AesDecryptCFB(encrypted []byte, key []byte) (decrypted []byte)
- func AesDecryptECB(encrypted []byte, key []byte) (decrypted []byte)
- func AesEncryptCBC(origData []byte, key []byte) (encrypted []byte)
- func AesEncryptCBCIV(origData []byte, key, iv []byte) (encrypted []byte)
- func AesEncryptCFB(origData []byte, key []byte) (encrypted []byte)
- func AesEncryptECB(origData []byte, key []byte) (encrypted []byte)
- func Base64Decode(data string) []byte
- func Base64Encode(data []byte) string
- func BytesToUint16(in []byte) uint16
- func BytesToUint16s(in []byte) (out []uint16)
- func BytesToUint32(in []byte) uint32
- func BytesToUint32s(in []byte) (out []uint32)
- func Get[T any](url string) (*T, error)
- func GetHeader[T any](url string, h map[string]string) (*T, error)
- func If[T any](cond bool, ifTrue T, ifFalse T) T
- func LoadConfig[T Config[T]]() (*T, error)
- func LoadConfigReader[T Config[T]](reader io.Reader) (*T, error)
- func MD5(s string) string
- func ObjsTrans[K, T any](objs []K, fn func(K) T) []T
- func Post[T any](url string, data any) (*T, error)
- func PostHeader[T any](url string, data any, h map[string]string) (*T, error)
- func RandString(n int) string
- func SHA(s string) string
- func TimeID() string
- func Uint16ToBytes(in uint16) (out []byte)
- func Uint32ToBytes(in uint32) (out []byte)
- type AppKey
- type BaseConfig
- type Config
- type Range
- type Ranges
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AesDecryptCBC ¶
func AesDecryptCBCIV ¶
func AesDecryptCFB ¶
func AesDecryptECB ¶
func AesEncryptCBC ¶
=================== CBC ======================
func AesEncryptCBCIV ¶
func AesEncryptCFB ¶
=================== CFB ======================
func AesEncryptECB ¶
=================== ECB ======================
func Base64Decode ¶
func Base64Encode ¶
func BytesToUint16 ¶
func BytesToUint16s ¶
func BytesToUint32 ¶
func BytesToUint32s ¶
func LoadConfig ¶
func ObjsTrans ¶
func ObjsTrans[K, T any](objs []K, fn func(K) T) []T
ObjsTrans concurrently transforms a slice of type K to a slice of type T using the provided transformation function fn.
This function processes each element of the input slice in parallel using goroutines, waits for all transformations to complete, and returns the resulting slice.
Parameters:
- objs: Input slice of type K to be transformed
- fn: Transformation function that converts a single element of type K to type T
Returns:
- []T: Slice containing the transformed elements in the same order as the input
Example:
// Convert []int to []string by converting each integer to its string representation
nums := []int{1, 2, 3, 4, 5}
strs := ObjsTrans(nums, func(n int) string {
return fmt.Sprintf("Number: %d", n)
})
func RandString ¶
func Uint16ToBytes ¶
func Uint32ToBytes ¶
Types ¶
type BaseConfig ¶
func (BaseConfig) Release ¶
func (b BaseConfig) Release() bool
Source Files
¶
Click to show internal directories.
Click to hide internal directories.