utils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteSlice

func DeleteSlice[T comparable](a []T, k T) []T

func Exif

func Exif() (*exiftool.Exiftool, error)

func GetFile

func GetFile(url string) ([]byte, error)

func GetFileName

func GetFileName(filename string) string

func GetFileNameExt

func GetFileNameExt(filename string) string

func GetFileNamePrefix

func GetFileNamePrefix(filename string) string

func GetPhotoSize

func GetPhotoSize(photo []byte) (width, hight int, err error)

func GetType

func GetType(data []byte) (string, error)

func In

func In[T comparable](slice []T, fun func(v T) bool) int

func Md5

func Md5(data []byte) string

func Parse2HTML added in v0.2.3

func Parse2HTML(str string) string

func PhotoColorInvert

func PhotoColorInvert(photo []byte) (InvertPhoto []byte, Err error)

func PrintStackTrace

func PrintStackTrace(err interface{}) string

func RandomString

func RandomString(n int) string

RandomString returns a random string with a fixed length

func Retry

func Retry(frequency uint, enableRecover bool, Delay time.Duration, fun func() (bool, error)) error

func Round

func Round(f float64, n int) float64

func TimeFomate

func TimeFomate(t time.Duration) string

func Translate

func Translate(text string) string

func TwoDot

func TwoDot(value float64) float64

Types

type Photo

type Photo struct {
	Width  int
	Height int
	Type   string
	Bytes  []byte
}

func CompressImageResource

func CompressImageResource(data []byte, quality uint) (*Photo, error)

func CompressImageResourceToSize

func CompressImageResourceToSize(data []byte, maxSize uint) (*Photo, error)

type RateLimiter

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

func NewRateLimiter

func NewRateLimiter(r rate.Limit, b int) *RateLimiter

func (*RateLimiter) AddIP

func (i *RateLimiter) AddIP(ip interface{}) *rate.Limiter

func (*RateLimiter) GetLimiter

func (i *RateLimiter) GetLimiter(ip interface{}) *rate.Limiter

Jump to

Keyboard shortcuts

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