utils

package
v0.9.18 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectContentType

func DetectContentType(filename string, content []byte) string

DetectContentType attempts to detect the MIME type of content It first tries to detect from the filename, then from the content itself

func ExtensionByMime

func ExtensionByMime(mimeType string) string

ExtensionByMime returns the most common file extension for a given MIME type

func GenerateSlugBatch

func GenerateSlugBatch(batchSize, length int) ([]string, error)

GenerateSlugBatch returns a batch of candidate slugs

func IsDebugEnabled

func IsDebugEnabled() bool

IsDebugEnabled returns true unless GIN_MODE=release

func IsTextContent

func IsTextContent(contentType string) bool

IsTextContent returns true if the content type is text-based

func IsValidSlug

func IsValidSlug(slug string) bool

IsValidSlug checks if a slug contains only valid characters

func SecureRandomSlug

func SecureRandomSlug(length int) (string, error)

SecureRandomSlug generates a random slug of given length using crypto/rand and a custom charset

Types

This section is empty.

Jump to

Keyboard shortcuts

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