Documentation
¶
Index ¶
- func Abs[T constraints.Integer | constraints.Float](x T) T
- func AbsoluteURL(root string, path ...string) string
- func Alter[T comparable](value *T, fallback T) T
- func ClearDirectory(dir string) error
- func Concat(sep string, parts ...string) string
- func CreateDirectory(path string) error
- func ExtractAlphaNum(s string, includes ...string) string
- func ExtractAlphaNumPersian(s string, includes ...string) string
- func ExtractNumbers(s string) string
- func FileExists(path string) (bool, error)
- func FindFile(dir string, pattern string) *string
- func FindFiles(dir string, pattern string) []string
- func FormatNumber(layout string, v ...any) string
- func FormatRx(data, pattern, repl string) (string, error)
- func GetExtension(file string) string
- func GetFilename(file string) string
- func GetMime(data []byte) *mimetype.MIME
- func GetSubDirectory(dir string) ([]string, error)
- func IsDirectory(path string) (bool, error)
- func IsEmpty[T comparable](value *T) bool
- func IsSame[T comparable](a, b *T) bool
- func Max[T constraints.Integer | constraints.Float](numbers ...T) T
- func Min[T constraints.Integer | constraints.Float](numbers ...T) T
- func NormalizePath(path ...string) string
- func NullableOf[T comparable](v *T) *T
- func NumberedFile(dir, file string) (string, error)
- func PointerOf[T any](value T) *T
- func RandomAlphaNum(n uint) string
- func RandomNumeric(n uint) string
- func RandomString(n uint, characters string) string
- func RelativeURL(root string, path ...string) string
- func Round[T constraints.Integer](x float64) T
- func RoundDown[T constraints.Integer](x float64) T
- func RoundUp[T constraints.Integer](x float64) T
- func SafeValue[T any](value *T) T
- func SanitizeCommon(data string, trim bool) string
- func SanitizeRaw(data string, trim bool) string
- func Slugify(parts ...string) string
- func SlugifyPersian(parts ...string) string
- func TimestampedFile(file string) string
- func ValueOf[T any](value *T, fallback T) T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Abs ¶
func Abs[T constraints.Integer | constraints.Float](x T) T
Abs returns the absolute value of x.
func AbsoluteURL ¶
AbsoluteURL returns the absolute URL path of file with respect to the root directory.
func Alter ¶
func Alter[T comparable](value *T, fallback T) T
Alter returns value of pointer or return fallback if value is nil or zero.
func ClearDirectory ¶
ClearDirectory delete all files and sub-directory in directory.
func CreateDirectory ¶
CreateDirectory create nested directory.
func ExtractAlphaNum ¶
ExtractAlphaNum extract alpha and numbers from string [a-zA-Z0-9].
func ExtractAlphaNumPersian ¶
ExtractAlphaNumPersian extract english and persian alpha and numbers from string [ا-یa-zA-Z0-9].
func ExtractNumbers ¶
ExtractNumbers extract numbers from string.
func FormatNumber ¶
FormatNumber format number with comma separator.
code block:
FormatNumber("%d Dollars", 100000)
output:
100,000 Dollars
func FormatRx ¶
FormatRx format string using regex pattern use () for match groups and $1, $2 for output placeholder.
code block:
FormatRx("123456", `(\d{3})(\d{2})(\d{1})`, "($1) $2-$3")
output:
(123) 45-6
func GetFilename ¶
GetFilename returns file name without extension.
func GetSubDirectory ¶
GetSubDirectory returns list of sub directories.
func IsDirectory ¶
IsDirectory check if path is directory
func Max ¶
func Max[T constraints.Integer | constraints.Float](numbers ...T) T
Max returns the largest value of numbers or zero.
func Min ¶
func Min[T constraints.Integer | constraints.Float](numbers ...T) T
Min returns the smallest value of numbers or zero.
func NormalizePath ¶
NormalizePath join and normalize file path.
func NumberedFile ¶
NumberedFile generate unique numbered file name (e.g. file.txt file-1.txt, file-2.txt).
func RandomAlphaNum ¶
RandomAlphaNum returns random string from Alpha-Num uppercase characters.
func RandomString ¶
RandomNumeric returns random string from character set.
func RelativeURL ¶
RelativeURL returns the relative URL path of file with respect to the root directory.
func Round ¶
func Round[T constraints.Integer](x float64) T
Round returns the nearest integer, rounding half away from zero.
func RoundDown ¶
func RoundDown[T constraints.Integer](x float64) T
RoundDown returns the nearest small integer.
func RoundUp ¶
func RoundUp[T constraints.Integer](x float64) T
RoundUp returns the nearest large integer (ceil).
func SafeValue ¶
func SafeValue[T any](value *T) T
SafeValue get value of pointer or return empty value if pointer is nil.
func SanitizeCommon ¶
SanitizeCommon sanitize input to html with common allowed tags.
func SanitizeRaw ¶
SanitizeRaw sanitize input to raw text.
func Slugify ¶
Slugify make url friendly slug from strings. Only Alpha-Num characters compiled to final result.
func SlugifyPersian ¶
SlugifyPersian make url friendly slug from strings. Only english and persian alpha and numberic characters compiled to final result.
func TimestampedFile ¶
TimestampedFile returns file name with timestamp prefix.
Types ¶
This section is empty.