extlib

package
v0.0.0-...-9cd5b15 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: BSD-2-Clause Imports: 7 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Std = exp.Builtins(make(lib.Specs).AddMap(lib.Std).AddMap(MustLib(
	Str, Time, UUID,
)))
View Source
var Str = FuncMap{
	"index":    strings.Index,
	"prefix":   strings.HasPrefix,
	"suffix":   strings.HasSuffix,
	"contains": strings.Contains,
	"upper":    strings.ToUpper,
	"lower":    strings.ToLower,
	"trim":     strings.TrimSpace,
	"like":     func(t, p string) bool { return Like(t, p, false) },
	"ilike":    func(t, p string) bool { return Like(t, p, true) },
}
View Source
var Time = FuncMap{
	"add_span":    time.Time.Add,
	"add_days":    AddDays,
	"add_date":    time.Time.AddDate,
	"sub_time":    time.Time.Sub,
	"year":        time.Time.Year,
	"month":       time.Time.Month,
	"weekday":     time.Time.Weekday,
	"yearday":     time.Time.YearDay,
	"day_start":   DayStart,
	"day_end":     DayEnd,
	"time_format": time.Time.Format,
	"fmt_date":    FmtDate,
	"fmt_time":    FmtTime,
	"fmt_human":   FmtTime,
}
View Source
var UUID = FuncMap{
	"new_uuid": cor.NewUUID,
}

Functions

func AddDays

func AddDays(t time.Time, days int) time.Time

func DayEnd

func DayEnd(t time.Time) time.Time

func DayStart

func DayStart(t time.Time) time.Time

func FmtDate

func FmtDate(t time.Time) string

func FmtHuman

func FmtHuman(t time.Time) string

func FmtTime

func FmtTime(t time.Time) string

func Lib

func Lib(fms ...FuncMap) (res lib.Specs, err error)

func Like

func Like(txt, term string, ignCase bool) bool

func MustLib

func MustLib(fms ...FuncMap) lib.Specs

Types

type FuncMap

type FuncMap map[string]interface{}

Jump to

Keyboard shortcuts

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