tools

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: Apache-2.0 Imports: 29 Imported by: 5

Documentation

Index

Constants

View Source
const (
	AlgMd5    = 1
	AlgSha1   = 2
	AlgSha256 = 3
)
View Source
const (
	BoxSizeRateMin           float32 = 0.1
	ImageQueryBoxSizeRateMin float32 = 0.1
)

Variables

View Source
var Reader io.Reader
View Source
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 CheckSum

func CheckSum(data []byte) uint32

compute checksum of input data.

func CreateDir

func CreateDir(path string, mode os.FileMode) error

create dir.

func CreateDirIfNotExists

func CreateDirIfNotExists(path string, mode os.FileMode) error

create dir if not exists.

func CurrentDateInSeconds

func CurrentDateInSeconds() int64

return the seconds representation of the current date in local

func CurrentTimeStr

func CurrentTimeStr() string

return current datetime in format yyyy-MM-dd HH:mm:ss

func DaysBefore

func DaysBefore(days int) int64

return the seconds representation of the start of days before now in local

func Decode

func Decode(jsonStr string, v interface{})

deserialize

func DecodeBytes

func DecodeBytes(jsonBytes []byte, v interface{}) error

deserialize

func DecodeFile

func DecodeFile(file string, v interface{}) error

deserialize file content.

func DeleteFile

func DeleteFile(path string) bool

remove file return false if failed.

func DeleteFiles

func DeleteFiles(path string) bool

remove dirs and files in path return false if failed.

func Encode

func Encode(v interface{}) string

serialize

func EncodeBytes

func EncodeBytes(v interface{}) []byte

serialize

func EncodeObj

func EncodeObj(v interface{}, file string) error

serialize object to file.

func FileCheckSum

func FileCheckSum(file string) uint32

compute checksum of the input file.

func FileExists

func FileExists(path string) bool

return true if file exists.

func Float32Round

func Float32Round(f float32, pOffset int64) float32

func GetTimeInSeconds

func GetTimeInSeconds(timeString string) int64

return the seconds representation of the timeString

timeString in format hhhmmmsss ,eg. 23h10m34s ,otherwise return -1

func HashUUID

func HashUUID(bs []byte) string

generate hash uuid of the input data.

func ImagEmpty

func ImagEmpty(a []uint8) float32

func ImageColorId

func ImageColorId(im image.Image) uint64

func ImageHashContentRate

func ImageHashContentRate(a uint64) float32

func ImageHashDiff

func ImageHashDiff(a, b uint64) float32

func ImageHashId

func ImageHashId(im image.Image, bs []byte) (image.Image, image.Image, uint64, error)

func ImageHashNull

func ImageHashNull(a uint64) uint8

func ImageMaskAllow

func ImageMaskAllow(masks [][]float32, x, y int, w, h int) bool

func ImagePixGray

func ImagePixGray(im image.Image, x, y int) uint8

func ImageSimilarity

func ImageSimilarity(a, b []uint8) float32

func ImageTag

func ImageTag(m image.Image, tagSpace int) []uint8

func ImgBytesDecode

func ImgBytesDecode(bs []byte) (image.Image, error)

func ImgShmBytes

func ImgShmBytes(file string) ([]byte, error)

func IsValidUUID

func IsValidUUID(UUID string) bool

check if UUID is in valid format.

func NewEmailSender

func NewEmailSender(user, password, server string) (*email, error)

func RandUUID

func RandUUID() string

generate random hash uuid.

func SplitSeconds

func SplitSeconds(seconds int64) (int64, int64)

return unix timestamp in seconds with two part:begin of a day and the offset

func TimeRingFromDaysAgo

func TimeRingFromDaysAgo(days int) *ring.Ring

return time ring from days ago util next day.

func TransTimeFormat

func TransTimeFormat(timeString string) string

Trans time format from hh:mm:ss to hhhmmmsss.If timeString format invalid return itself

eg. 23:10:34 => 23h10m34s

Types

type EmailOption

type EmailOption func(email *email)

func Bcc

func Bcc(bcc string) EmailOption

func Cc

func Cc(cc string) EmailOption

func ReplyTo

func ReplyTo(replyTo string) EmailOption

func ReturnPath

func ReturnPath(returnPath string) EmailOption

func Subject

func Subject(subject string) EmailOption

func UserName

func UserName(name string) EmailOption

type Message

type Message struct {
	// contains filtered or unexported fields
}

func AttachmentMessage

func AttachmentMessage(name, filePath, contentId string) *Message

func HtmlMessage

func HtmlMessage(format string, args ...interface{}) *Message

func TextMessage

func TextMessage(format string, args ...interface{}) *Message

Jump to

Keyboard shortcuts

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