cyutil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ToString = cytype.ToString

Functions

func Base64Decode

func Base64Decode(v string) string

func Base64Encode

func Base64Encode(v string) string

func CheckDependencies added in v1.0.0

func CheckDependencies(deps ...string) error

func CheckDependenciesWithWarning added in v1.0.0

func CheckDependenciesWithWarning(deps ...string)

func CopyDir added in v1.0.0

func CopyDir(src, dst string) error

func CopyFile added in v1.0.0

func CopyFile(src, dst string) error

func CopyPath added in v1.0.0

func CopyPath(src, dst string) error

func Diff

func Diff(oldDatas, newDatas []map[string]interface{}, key string) (newData, updateData, delData []map[string]interface{})

func EnsureDir added in v1.0.0

func EnsureDir(dir string) error

func ExtractTarGz added in v1.0.0

func ExtractTarGz(targzPath, targetDir string) error

func FormatDuration

func FormatDuration(d stdtime.Duration) string

func FormatTime added in v1.0.0

func FormatTime(value interface{}, layout string) string

func FormatTimeE added in v1.0.0

func FormatTimeE(value interface{}, layout string) (string, error)

func FromJsonE added in v1.0.0

func FromJsonE[T any](b string) (*T, error)

func GenHMAC

func GenHMAC(data string, key string) string

func GetBool

func GetBool(m map[string]interface{}, key string, igoreCase ...bool) bool

func GetBoolE added in v1.0.0

func GetBoolE(m map[string]interface{}, key string, igoreCase ...bool) (bool, error)

func GetExeDir added in v1.0.0

func GetExeDir() (string, error)

func GetFloat

func GetFloat(m map[string]interface{}, key string, igoreCase ...bool) float64

func GetFloatE added in v1.0.0

func GetFloatE(m map[string]interface{}, key string, igoreCase ...bool) (float64, error)

func GetInt

func GetInt(m map[string]interface{}, key string, igoreCase ...bool) int

func GetInt64

func GetInt64(m map[string]interface{}, key string, igoreCase ...bool) int64

func GetInt64E added in v1.0.0

func GetInt64E(m map[string]interface{}, key string, igoreCase ...bool) (int64, error)

func GetIntE added in v1.0.0

func GetIntE(m map[string]interface{}, key string, igoreCase ...bool) (int, error)

func GetJwtVal added in v1.0.0

func GetJwtVal(token string) (*cycrypto.JwtData, error)

func GetParentDirName added in v1.0.0

func GetParentDirName(path string) (string, error)

func GetSignature

func GetSignature(method, key string, queryParam map[string]string) string

func GetSignatureFromURL

func GetSignatureFromURL(method, key, url string) (string, error)

func GetStr

func GetStr(m map[string]interface{}, key string, igoreCase ...bool) string

func GetStrE added in v1.0.0

func GetStrE(m map[string]interface{}, key string, igoreCase ...bool) (string, error)

func GetStructFieldTags added in v1.0.0

func GetStructFieldTags[T any](tagName string, tagKey ...string) ([]string, error)

func GetVal

func GetVal[T any](m map[string]interface{}, key string, igoreCase ...bool) T

func GetValue

func GetValue(m map[string]interface{}, keys []string, ignoreCase ...bool) (interface{}, error)

func GraphSort

func GraphSort(names []string, depGraph map[string]map[string]struct{}) ([]string, error)

func HasCommand added in v1.0.0

func HasCommand(cmd string) bool

func HasSudoAccess added in v1.0.0

func HasSudoAccess() bool

func HashInt

func HashInt(input string) uint32

func IsDigits

func IsDigits(s string) bool

func IsDir added in v1.0.0

func IsDir(path string) bool

func IsRoot added in v1.0.0

func IsRoot() bool

func JwtSign added in v1.0.0

func JwtSign(data *cycrypto.JwtData) (string, error)

func JwtSignWithTTL added in v1.0.0

func JwtSignWithTTL(data *cycrypto.JwtData, ttl stdtime.Duration) (string, error)

func MD5

func MD5(params ...interface{}) string

func MatchFiles added in v1.0.0

func MatchFiles(dir, rule string) ([]string, error)

func MatchSingleFile added in v1.0.0

func MatchSingleFile(dir, rule string) (string, error)

func MatchSingleFileOrEmpty added in v1.0.0

func MatchSingleFileOrEmpty(dir, rule string) (string, error)

func Md5Concat added in v1.0.0

func Md5Concat(params ...interface{}) string

func MergeMaps

func MergeMaps(m1 ...map[string]interface{}) map[string]interface{}

func MovePath added in v1.0.0

func MovePath(src, dst string) error

func NanoID

func NanoID(l ...int) string

func NewObj

func NewObj[T any]() (T, bool)

func PadStart

func PadStart(s string, length int, pad string) string

func ParseQueryToMap

func ParseQueryToMap(queryString string) (map[string]string, error)

func ParseURLParams

func ParseURLParams(url string) (string, map[string]string, error)

func ParseUserAgent

func ParseUserAgent(ua string) string

func PathExists added in v1.0.0

func PathExists(path string) bool

func Ptr

func Ptr[T any](v T) *T

func ReadFileFromZip added in v1.0.0

func ReadFileFromZip(zipPath string, filePath string) ([]byte, error)

func RealVal

func RealVal(encodeVal string) string

func RemovePath added in v1.0.0

func RemovePath(path string) error

func RemoveSqlComments

func RemoveSqlComments(line string, inMultiLineComment bool) (processedLine string, stillInComment bool)

func ReplaceSqlStringContent

func ReplaceSqlStringContent(line string, expectedEnd string, vPlaceholder ...string) (processedLine string, nextExpectedEnd string)

func RequireRootOrSudo added in v1.0.0

func RequireRootOrSudo() error

func SM4Decode2

func SM4Decode2(v string) string

func SetValue

func SetValue(m map[string]interface{}, keys []string, value interface{}) (bool, error)

func SliceContains added in v1.0.0

func SliceContains(slice []string, item string, ignoreCase ...bool) bool

func SliceToAny

func SliceToAny[T any](s []T) []any

func SnowflakeID

func SnowflakeID() string

func SortParam

func SortParam(method string, params map[string]string) string

func SplitFilePath added in v1.0.0

func SplitFilePath(filePath string) (string, string, string)

func ToBool

func ToBool(value interface{}) bool

func ToBoolE added in v1.0.0

func ToBoolE(value interface{}) (bool, error)

func ToFloat64

func ToFloat64(value interface{}) float64

func ToFloat64E added in v1.0.0

func ToFloat64E(value interface{}) (float64, error)

func ToInt

func ToInt(value interface{}) int

func ToInt64

func ToInt64(value interface{}) int64

func ToInt64E added in v1.0.0

func ToInt64E(value interface{}) (int64, error)

func ToIntE added in v1.0.0

func ToIntE(value interface{}) (int, error)

func ToJsonE added in v1.0.0

func ToJsonE[T any](d T) (string, error)

func ToStr

func ToStr(value any) string

func ToStrE added in v1.0.0

func ToStrE(value interface{}) (string, error)

func ToTime added in v1.0.0

func ToTime(value interface{}) stdtime.Time

func ToTimeE added in v1.0.0

func ToTimeE(value interface{}) (stdtime.Time, error)

func ToTimestamp

func ToTimestamp(tm stdtime.Time) int64

func TravelMap

func TravelMap(m map[string]any, f func(k string, v any) error) error

func TravelMapEx added in v1.0.0

func TravelMapEx(m map[string]any, parentKey []any, f func(k []any, v any) error) error

func TraverseString

func TraverseString(s string, separatorChars string, callback cyalgorithm.CallbackFunc) error

func UUID

func UUID() string

func UnzipFile added in v1.0.0

func UnzipFile(zipfile, target string) error

func WalkMapLeaves

func WalkMapLeaves(root map[string]any, f func(path string, v any) error) error

func WalkZip added in v1.0.0

func WalkZip(zipfile string, ext string, proc func(path string, r io.Reader) error) error

func WalkZipOrdered added in v1.0.0

func WalkZipOrdered(zipfile string, ext string, proc func(path string, r io.Reader) error, sorts ...string) error

func WalkerZip added in v1.0.0

func WalkerZip(zipfile string, ext string, proc func(path string, r io.Reader) error) error

func XID

func XID() string

func ZipFolder added in v1.0.0

func ZipFolder(folder string) (string, error)

Types

type CallbackFunc

type CallbackFunc = cyalgorithm.CallbackFunc

type DelimiterInfo

type DelimiterInfo = stringutil.DelimiterInfo

func FindDelimiters

func FindDelimiters(str, sep string) []DelimiterInfo

type JwtData added in v1.0.0

type JwtData = cycrypto.JwtData

type WordInfo

type WordInfo = cyalgorithm.WordInfo

Directories

Path Synopsis
deep_copy.go
deep_copy.go

Jump to

Keyboard shortcuts

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