Documentation
¶
Index ¶
- Constants
- Variables
- func CheckSum(data []byte) uint32
- func ComputeAge(birthStr string, baseDate *time.Time) (age int)
- func Copy(src any, dest any) error
- func CreateDir(path string, mode os.FileMode) error
- func CreateDirIfNotExists(path string, mode os.FileMode) error
- func CurrentDataCompactStr() string
- func CurrentDateInSeconds() int64
- func CurrentDateStr() string
- func CurrentDateTimeStr() string
- func CurrentTimeCompactStr() string
- func DaysBefore(days int) int64
- func Decode(jsonStr string, v any)
- func DecodeBytes(jsonBytes []byte, v any) error
- func DecodeFile(file string, v any) error
- func DecodeJson5(filePath string, output any) error
- func DeleteFile(path string) bool
- func DeleteFiles(path string) bool
- func DoGet(rawUrl, uri, token string, params *url.Values, result any) (code int, err error)
- func DoPost(rawUrl, uri string, token string, params *url.Values, body any, result any) (code int, err error)
- func DoRequest(method, rawUrl, uri string, params *url.Values, header *http.Header, ...) (resp *http.Response, err error)
- func Encode(v any) string
- func EncodeBytes(v any) []byte
- func EncodeObj(v any, file string) error
- func ExtractCerInfo(cerNo string) (province, city, district, birthStr string, birth int64, age int, isMale int8)
- func FileCheckSum(file string) uint32
- func FileExists(path string) bool
- func Float32Round(f float32, pOffset int64) float32
- func GetTimeInSeconds(timeStr string) int64
- func GetToken(method, rawUrl, uri, user, password string) (token string, err error)
- func HashUUID(bs []byte) string
- func ImagEmpty(a []uint8) float32
- func ImageColorId(im image.Image) uint64
- func ImageHashContentRate(a uint64) float32
- func ImageHashDiff(a, b uint64) float32
- func ImageHashId(im image.Image, bs []byte) (image.Image, image.Image, uint64, error)
- func ImageHashNull(a uint64) uint8
- func ImageMaskAllow(masks [][]float32, x, y int, w, h int) bool
- func ImagePixGray(im image.Image, x, y int) uint8
- func ImageSimilarity(a, b []uint8) float32
- func ImageTag(m image.Image, tagSpace int) []uint8
- func ImgBytesDecode(bs []byte) (image.Image, error)
- func ImgShmBytes(file string) ([]byte, error)
- func IsType[T any](a any) bool
- func IsValidCardNo18(CardNo18 *[]byte) bool
- func IsValidUUID(UUID string) bool
- func LocalIP() (ip string)
- func ParseResponse(resp *http.Response, result any) (code int, err error)
- func RandUUID() string
- func RandomAlphaNum(length int) string
- func RandomNumChar(length int) string
- func ReadFile(filename string, preRead int) (<-chan string, context.CancelFunc, error)
- func Sign(raw []byte, algo string) (signature []byte)
- func SplitSeconds(seconds int64) (int64, int64)
- func TimeRingFromDaysAgo(days int) *ring.Ring
- func ToAny[T any](a any) T
- func ToAnyE[T any](a any) (T, bool)
- func TransTimeFormat(timeString string) string
Constants ¶
const ( AlgMd5 = 1 AlgSha1 = 2 AlgSha256 = 3 )
const ( BoxSizeRateMin float32 = 0.1 ImageQueryBoxSizeRateMin float32 = 0.1 )
const ( SignatureAlgorithmMD5 = "MD5" SignatureAlgorithmHMACSHA256 = "HMACSHA256" )
Variables ¶
var Reader io.Reader
var UUIDRegexp = regexp.MustCompile(fmt.Sprintf("^[a-f0-9]{8}%c([a-f0-9]{4}%c){3}[a-f0-9]{12}$", uuidDash, uuidDash))
Functions ¶
func CreateDirIfNotExists ¶
CreateDirIfNotExists create dir if not exists.
func CurrentDataCompactStr ¶ added in v0.0.2
func CurrentDataCompactStr() string
CurrentDataCompactStr return current date in format yyyyMMdd
func CurrentDateInSeconds ¶
func CurrentDateInSeconds() int64
CurrentDateInSeconds return the seconds representation of the current date in local
func CurrentDateStr ¶ added in v0.0.2
func CurrentDateStr() string
CurrentDateStr return current date in format yyyy-MM-dd
func CurrentDateTimeStr ¶ added in v0.0.2
func CurrentDateTimeStr() string
CurrentDateTimeStr return current datetime in format yyyy-MM-dd HH:mm:ss
func CurrentTimeCompactStr ¶ added in v0.0.2
func CurrentTimeCompactStr() string
CurrentTimeCompactStr return current time in format HHmmss
func DaysBefore ¶
DaysBefore return the seconds representation of the start of days before now in local
func DecodeJson5 ¶ added in v0.0.3
func DeleteFiles ¶
DeleteFiles remove dirs and files in path return false if failed.
func ExtractCerInfo ¶ added in v0.0.3
func ExtractCerInfo(cerNo string) (province, city, district, birthStr string, birth int64, age int, isMale int8)
ExtractCerInfo isMale 1:女性 2:男性
func FileCheckSum ¶
FileCheckSum compute checksum of the input file.
func Float32Round ¶
func GetTimeInSeconds ¶
GetTimeInSeconds return the seconds representation of the timeString
timeStr in format hhhmmmsss ,e.g. 23h10m34s ,otherwise return -1
func ImageColorId ¶
func ImageHashContentRate ¶
func ImageHashDiff ¶
func ImageHashId ¶
func ImageHashNull ¶
func ImageSimilarity ¶
func ImgShmBytes ¶
func IsValidCardNo18 ¶ added in v0.0.3
func ParseResponse ¶ added in v0.0.3
func RandomAlphaNum ¶ added in v0.0.3
func RandomNumChar ¶ added in v0.0.3
func SplitSeconds ¶
SplitSeconds return unix timestamp in seconds with two part:begin of a day and the offset
func TimeRingFromDaysAgo ¶
TimeRingFromDaysAgo return time ring from days ago util next day.
func TransTimeFormat ¶
TransTimeFormat Trans time format from hh:mm:ss to hhhmmmsss.If timeString format invalid return itself
eg. 23:10:34 => 23h10m34s
Types ¶
This section is empty.