utils

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockEntity        string = "blocks"
	WebhookEntity      string = "webhooks"
	PageEntity         string = "pages"
	PeriodicTaskEntity string = "periodic_tasks"
)

Variables

This section is empty.

Functions

func AlertBox

func AlertBox(messageType AlertType, message string) string

func DefaultHtml

func DefaultHtml(input any, defaultValue string) template.HTML

defaultString returns the default string if the input is empty.

func DefaultString

func DefaultString(input any, defaultValue string) string

func FormatDateTime

func FormatDateTime(datetime time.Time) string

func GenerateHTML

func GenerateHTML(tmpl string, data any) (string, error)

func GenerateRandomString

func GenerateRandomString(length int) (string, error)

GenerateRandomString creates a random string of a specified length

func GetFieldValue

func GetFieldValue(input any, fieldName string) (any, error)

func GetMapKeys

func GetMapKeys[T any](m map[string]T) []string

func IsCommandAvailable

func IsCommandAvailable(cmd string) bool

func IsCronValid

func IsCronValid(fl validator.FieldLevel) bool

func MergeMaps

func MergeMaps[K comparable, V any](map1, map2 map[K]V) map[K]V

MergeMaps merges two maps. Values from map2 will overwrite values from map1 if keys are the same.

func ParseInt

func ParseInt(s string) int

func ParseInt64

func ParseInt64(s string) int64

func PrintBanner

func PrintBanner(viewsFS embed.FS, data any)

func RemoveDuplicates

func RemoveDuplicates(input []string) []string

func ToMap

func ToMap(data any) map[string]any

func ToastHeader

func ToastHeader(message string) (string, string)

func TransformToMaps

func TransformToMaps[T any](items []T, typeName string) []map[string]any

transformToMaps is the generic function to transform any slice to []map[string]any

Types

type AlertType

type AlertType string

Define a custom type for restricted strings

const (
	Info    AlertType = "primary"
	Success AlertType = "success"
	Error   AlertType = "danger"
	Warning AlertType = "warning"
)

Define constants for allowed values

Jump to

Keyboard shortcuts

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