utils

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeHTML

func EscapeHTML(s string) string

EscapeHTML escapes special HTML characters

func ExtractBool

func ExtractBool(data map[string]interface{}, key string) bool

ExtractBool safely extracts a boolean value from a map

func ExtractFloat64

func ExtractFloat64(data map[string]interface{}, key string) float64

ExtractFloat64 safely extracts a float64 value from a map

func ExtractInt

func ExtractInt(data map[string]interface{}, key string) int

ExtractInt safely extracts an integer value from a map

func ExtractMap

func ExtractMap(data map[string]interface{}, key string) map[string]interface{}

ExtractMap safely extracts a map value from a map

func ExtractSlice

func ExtractSlice(data map[string]interface{}, key string) []interface{}

ExtractSlice safely extracts a slice value from a map

func ExtractString

func ExtractString(data map[string]interface{}, key string) string

ExtractString safely extracts a string value from a map

func RawHTML

func RawHTML(s string) template.HTML

RawHTML creates a template.HTML without escaping (use with caution)

func SafeHTML

func SafeHTML(s string) template.HTML

SafeHTML creates a template.HTML from an escaped string

func UnmarshalToMap

func UnmarshalToMap(data json.RawMessage) (map[string]interface{}, error)

UnmarshalToMap unmarshals JSON data into a map[string]interface{}

func UnmarshalToSlice

func UnmarshalToSlice(data json.RawMessage) ([]interface{}, error)

UnmarshalToSlice unmarshals JSON data into a []interface{}

func ValidateRequiredField

func ValidateRequiredField(data map[string]interface{}, field string) error

ValidateRequiredField checks that a single required field is present

func ValidateRequiredFields

func ValidateRequiredFields(data map[string]interface{}, fields ...string) error

ValidateRequiredFields checks that all required fields are present in the data map

Types

This section is empty.

Jump to

Keyboard shortcuts

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