Documentation ¶
Index ¶
- Constants
- Variables
- func AesDecode(key, cipherText []byte) ([]byte, error)
- func AesEncode(key, plainText []byte) ([]byte, error)
- func AsyncDo[K any](ctx context.Context, inputs []K, fn func(context.Context, K) error) error
- func AsyncResult[K, V any](ctx context.Context, inputs []K, fn func(context.Context, K) (V, error)) ([]V, error)
- func Base64Decode(data string) ([]byte, error)
- func Base64Encode(data []byte) string
- func ByteSizeString(b int64) string
- func CRC32(data []byte) uint32
- func CRC32File(path string) (uint32, error)
- func CRC32String(s string) uint32
- func CacheGet(ctx context.Context, providor CacheProvidor, key string, expire time.Duration, ...) ([]byte, error)
- func CacheHash(data any) string
- func CeilDiv[T Integer](x, y T) T
- func CheckPasswordHash(password, hash string) bool
- func CompileRegexp(exp string) *regexp.Regexp
- func Contains[T comparable](slice []T, element T) bool
- func CopyFile(src, dst string) error
- func Download(url string, timeout time.Duration) ([]byte, error)
- func DownloadFile(url, path string, timeout time.Duration) error
- func EscapeSQLString(sql string) string
- func Exec(command string, args []string, stdin []byte) ([]byte, error)
- func FileExist(path string) bool
- func Filter[V any](slice []V, fn func(V) bool) []V
- func Fnv1(data []byte) uint64
- func Fnv1String(s string) uint64
- func FormatDate(t time.Time) string
- func FormatTime(t time.Time) string
- func FromJSON(data []byte, v any) error
- func FromJSONString(data string, v any) error
- func GetEnvBool(name string) bool
- func GetEnvString(name string) string
- func GetGithubLastestRelease(owner, repo, filename string) (tag, url string, err error)
- func HttpAdvancedGet(url string, header map[string]string, timeout time.Duration) ([]byte, error)
- func HttpAdvancedPost(url string, header map[string]string, body []byte, timeout time.Duration) ([]byte, error)
- func HttpGet(url string) ([]byte, error)
- func HttpPost(url string, body []byte) ([]byte, error)
- func HttpPostJSON(url string, data any) ([]byte, error)
- func If[T any](condition bool, ifOutput T, elseOutput T) T
- func Keys[K comparable, V any](m map[K]V) []K
- func LoadEnvFile(filename string) error
- func MD5(data []byte) string
- func MD5File(path string) (string, error)
- func MD5String(s string) string
- func Main(fn func() error)
- func Map[T any, R any](slice []T, fn func(T) R) []R
- func Max[T Number](nums ...T) T
- func Min[T Number](nums ...T) T
- func Now() string
- func PageCount[T Integer](totalRows, pageSize T) T
- func PageOffset[T Integer](pageNum, pageSize T) T
- func ParseTime(s string) (time.Time, error)
- func PasswordHash(password string) (string, error)
- func Pkcs7Pad(buf []byte, size int) ([]byte, error)
- func Pkcs7Unpad(buf []byte) ([]byte, error)
- func RandBytes(length int) []byte
- func RandInt(n int) int
- func RandRange(min, max int) int
- func RandString(length int) string
- func ReadFileLineByLine(path string) ([]string, error)
- func ReadFileToString(path string) (string, error)
- func RegexpFindString(exp, data string) [][]string
- func SHA1(data []byte) string
- func SHA1File(path string) (string, error)
- func SHA1String(s string) string
- func SHA256(data []byte) string
- func SHA256File(path string) (string, error)
- func SHA256String(s string) string
- func SignECDSA(r io.Reader, privKey []byte) (string, error)
- func StringToBool(s string) bool
- func Time() int64
- func TimeMax(times ...time.Time) time.Time
- func TimeMin(times ...time.Time) time.Time
- func ToJSON(data any) ([]byte, error)
- func ToJSONString(data any) (string, error)
- func ToJSONStringNoError(data any) string
- func Today() string
- func TouchFile(fileName string) error
- func UUID() string
- func Uniq[T comparable](slice []T) []T
- func Values[K comparable, V any](m map[K]V) []V
- func VerifyECDSA(r io.Reader, pubKey []byte, sign string) (bool, error)
- func WorkerDo[K any](ctx context.Context, workerNum int, inputs []K, ...) error
- func WorkerResult[K, V any](ctx context.Context, workerNum int, inputs []K, ...) ([]V, error)
- func WriteKeyValueToString(data KeyVals) string
- func Yesterday() string
- type CacheProvidor
- type FetchFn
- type Float
- type GithubReleaseAsset
- type GithubReleaseItem
- type Int
- type Integer
- type KeyVals
- type Number
- type Uint
Constants ¶
View Source
const ( DateFormat = "2006-01-02" TimeFormat = "2006-01-02 15:04:05" )
Variables ¶
View Source
var ErrFormatNotSupport = errors.New("format not support")
View Source
var MemCacheProvidor *memCacheProvidor
Functions ¶
func AsyncResult ¶
func Base64Decode ¶
func Base64Encode ¶
func ByteSizeString ¶
func CRC32String ¶
func CheckPasswordHash ¶
func CompileRegexp ¶
func Contains ¶
func Contains[T comparable](slice []T, element T) bool
func EscapeSQLString ¶
func Fnv1String ¶
func FormatDate ¶
func FormatTime ¶
func FromJSONString ¶
func GetEnvBool ¶
func GetEnvString ¶
func GetGithubLastestRelease ¶
func HttpAdvancedGet ¶
func HttpAdvancedPost ¶
func Keys ¶
func Keys[K comparable, V any](m map[K]V) []K
func LoadEnvFile ¶
func PageOffset ¶
func PageOffset[T Integer](pageNum, pageSize T) T
func Pkcs7Unpad ¶
func RandString ¶
func ReadFileLineByLine ¶
func ReadFileToString ¶
func RegexpFindString ¶
func SHA1String ¶
func SHA256File ¶
func SHA256String ¶
func StringToBool ¶
func ToJSONString ¶
func ToJSONStringNoError ¶
func Uniq ¶
func Uniq[T comparable](slice []T) []T
func Values ¶
func Values[K comparable, V any](m map[K]V) []V
func WorkerResult ¶
func WriteKeyValueToString ¶
Types ¶
type CacheProvidor ¶
type GithubReleaseAsset ¶
type GithubReleaseItem ¶
type GithubReleaseItem struct { Name string `json:"name"` TagName string `json:"tag_name"` CreatedAt time.Time `json:"created_at"` PublishedAt time.Time `json:"published_at"` Assets []GithubReleaseAsset `json:"assets"` }
func ListGithubRelease ¶
func ListGithubRelease(owner, repo string) ([]GithubReleaseItem, error)
type KeyVals ¶
func ReadKeyValueFromString ¶
Click to show internal directories.
Click to hide internal directories.