utils

package
v0.0.0-...-175e951 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectMIMEType

func DetectMIMEType(data *([]byte)) string

func GenerateLockKey

func GenerateLockKey(identifier string) int64

func GetEnv

func GetEnv(key, fallback string) string

func GetExtFromFilename

func GetExtFromFilename(filename string) string

func GetExtFromMIMEType

func GetExtFromMIMEType(mimeType string) string

func GetImageDimensions

func GetImageDimensions(imageBytes []byte) (int32, int32, error)

func GetMimeTypeFromFilename

func GetMimeTypeFromFilename(filename string) string

func IsStrTruthy

func IsStrTruthy(s string) bool

func JsonEscape

func JsonEscape(i string) string

func MaybeRemoveExif

func MaybeRemoveExif(data []byte) ([]byte, error)

func Reversed

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

func RunWithLock

func RunWithLock(lock MutexLock, fn func() error) error

func RunWorkerPool

func RunWorkerPool[T any](tasks []WorkerTask[T], maxWorkers int) chan workerResult[T]

func SafeDeref

func SafeDeref[T any](p *T) T

func SafeDerefWithDefault

func SafeDerefWithDefault[T any](p *T, defaultValue T) T

func Slugify

func Slugify(s string, lower ...bool) string

Types

type Lazy

type Lazy[T any] struct {
	New func() T
	// contains filtered or unexported fields
}

func NewLazy

func NewLazy[T any](newfunc func() T) *Lazy[T]

func (*Lazy[T]) Value

func (this *Lazy[T]) Value() T

type MutexLock

type MutexLock interface {
	AcquireLock() (bool, error)
	ReleaseLock() error
}

type PgAdvisoryLock

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

func NewPgAdvisoryLock

func NewPgAdvisoryLock(db *sql.DB, lockKey int64) *PgAdvisoryLock

func (*PgAdvisoryLock) AcquireLock

func (p *PgAdvisoryLock) AcquireLock() (bool, error)

func (*PgAdvisoryLock) ReleaseLock

func (p *PgAdvisoryLock) ReleaseLock() error

type RedisLock

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

func NewRedisLock

func NewRedisLock(client *redis.Client, key string, ttl time.Duration) *RedisLock

func (*RedisLock) AcquireLock

func (r *RedisLock) AcquireLock() (bool, error)

func (*RedisLock) ReleaseLock

func (r *RedisLock) ReleaseLock() error

type SeekerReader

type SeekerReader interface {
	io.Seeker
	io.Reader
}

type WorkerTask

type WorkerTask[T any] struct {
	Job     T
	Execute func(T) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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