funcs

package
v0.0.0-...-c304cca Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var TemplateFuncs = template.FuncMap{

	"now":            time.Now,
	"timeSince":      time.Since,
	"timeUntil":      time.Until,
	"formatTime":     formatTime,
	"approxDuration": approxDuration,

	"uppercase": strings.ToUpper,
	"lowercase": strings.ToLower,
	"pluralize": pluralize,
	"slugify":   slugify,
	"safeHTML":  safeHTML,

	"join":           strings.Join,
	"containsString": slices.Contains[string],

	"incr":        incr,
	"decr":        decr,
	"formatInt":   formatInt,
	"formatFloat": formatFloat,

	"yesno": yesno,

	"urlSetParam": urlSetParam,
	"urlDelParam": urlDelParam,
}

Functions

func BackgroundFunc

func BackgroundFunc(fn func())

BackgroundFunc executes a given function in a goroutine.

func GetEnv

func GetEnv(val, defaultVal string) string

GetEnv improves on os.Getenv by setting a default value if the variable is not set

Example
fmt.Println(GetEnv("NOT_EXIST", "default"))
_ = os.Setenv("DOES_EXIST", "i_exist")
fmt.Println(GetEnv("DOES_EXIST", "i_exist"))
Output:

default
i_exist

Types

This section is empty.

Jump to

Keyboard shortcuts

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