Documentation ¶
Index ¶
- Variables
- func AsBytes(v interface{}) []byte
- func AsDuration(val any) (typedVal time.Duration, err error)
- func AsFloat64(val interface{}) (typedVal float64, err error)
- func AsInt(val interface{}) (typedVal int, err error)
- func AsString(v any) string
- func AtIndex(index int, collection interface{}) (interface{}, error)
- func Base64(v string) string
- func Base64Decode(v string) (string, error)
- func CSV(collection interface{}) (string, error)
- func Ceil(d float64) float64
- func Concat(strs ...string) string
- func Contains(substr, v string) bool
- func ControlFor(obj any, fieldName string) template.HTML
- func DurationRound(d time.Duration, to time.Duration) time.Duration
- func DurationRoundMillis(d time.Duration) time.Duration
- func DurationRoundSeconds(d time.Duration) time.Duration
- func FileExists(path string) bool
- func First(collection interface{}) (interface{}, error)
- func Floor(d float64) float64
- func FormFor(obj any, action string) template.HTML
- func FormatFileSize(sizeBytes int) string
- func FormatMoney(d float64) string
- func FormatPct(d float64) string
- func GenerateKey(keySize int) string
- func GenerateOrdinalNames(format string, replicas int) []string
- func HMAC512(key, v string) (string, error)
- func HasPrefix(prefix, v string) bool
- func HasSuffix(suffix, v string) bool
- func IndentSpaces(spaceCount int, v interface{}) string
- func IndentTabs(tabCount int, v interface{}) string
- func Join(sep string, collection any) (string, error)
- func Last(collection interface{}) (interface{}, error)
- func Matches(expr, v string) (bool, error)
- func ParseBool(raw interface{}) (bool, error)
- func ParseFloat64(v string) (float64, error)
- func ParseInt(v interface{}) (int, error)
- func ParseInt64(v interface{}) (int64, error)
- func ParseJSON(v string) (interface{}, error)
- func ParseTime(format, v string) (time.Time, error)
- func ParseTimeUnix(v int64) time.Time
- func ParseURL(v string) (*url.URL, error)
- func ParseUUID(v string) (uuid.UUID, error)
- func Prefix(pref, v string) string
- func Quote(v string) string
- func ReadFile(path string) (string, error)
- func Render(templateText string, model any) (template.HTML, error)
- func Reverse(collection interface{}) (interface{}, error)
- func Round(places, d float64) float64
- func SHA256(v string) string
- func SHA512(v string) string
- func SequenceRange(start, end int) []int
- func Slice(from, to int, collection interface{}) (interface{}, error)
- func Slugify(v string) string
- func Split(sep, v string) []string
- func SplitN(sep string, n float64, v string) []string
- func StripQuotes(v string) string
- func Suffix(suf, v string) string
- func TSV(collection interface{}) (string, error)
- func TimeDay(t time.Time) int
- func TimeFormat(format string, t time.Time) string
- func TimeFormatDateLong(t time.Time) string
- func TimeFormatDateMonthDay(t time.Time) string
- func TimeFormatDateShort(t time.Time) string
- func TimeFormatDateShortRev(t time.Time) string
- func TimeFormatKitchen(t time.Time) string
- func TimeFormatMedium(t time.Time) string
- func TimeFormatRFC3339(t time.Time) string
- func TimeFormatShort(t time.Time) string
- func TimeHour(t time.Time) int
- func TimeInLocation(loc string, t time.Time) (time.Time, error)
- func TimeInUTC(t time.Time) time.Time
- func TimeIsEpoch(t time.Time) bool
- func TimeIsZero(t time.Time) bool
- func TimeMillisecond(t time.Time) int
- func TimeMinute(t time.Time) int
- func TimeMonth(t time.Time) int
- func TimeNow() time.Time
- func TimeNowUTC() time.Time
- func TimeSecond(t time.Time) int
- func TimeSince(t time.Time) time.Duration
- func TimeSinceUTC(t time.Time) time.Duration
- func TimeSub(t1, t2 time.Time) time.Duration
- func TimeUnix(t time.Time) int64
- func TimeUnixNano(t time.Time) int64
- func TimeYear(t time.Time) int
- func ToJSON(v any) (string, error)
- func ToJSONPretty(v any) (string, error)
- func ToLower(v string) string
- func ToTitle(v string) string
- func ToUpper(v string) string
- func TrimPrefix(prefix, v string) string
- func TrimSpace(v string) string
- func TrimSuffix(suffix, v string) string
- func URLEncode(value string) string
- func URLHost(v *url.URL) string
- func URLPath(v *url.URL) string
- func URLPort(v *url.URL) string
- func URLQuery(name string, v *url.URL) string
- func URLRawQuery(v *url.URL) string
- func URLScheme(v *url.URL) string
- func UUIDv4() uuid.UUID
- func WithURLHost(host string, u *url.URL) *url.URL
- func WithURLPath(path string, u *url.URL) *url.URL
- func WithURLPort(port string, u *url.URL) *url.URL
- func WithURLQuery(key, value string, u *url.URL) *url.URL
- func WithURLRawQuery(rawQuery string, u *url.URL) *url.URL
- func WithURLScheme(scheme string, u *url.URL) *url.URL
- type FormProvider
- type InputProvider
Constants ¶
This section is empty.
Variables ¶
var (
Funcs template.FuncMap = map[string]any{}/* 101 elements not displayed */
)
Funcs is a singleton for viewfuncs.
Functions ¶
func AsBytes ¶
func AsBytes(v interface{}) []byte
AsBytes attempts to return a bytes representation of a value.
func AsDuration ¶
AsDuration returns a given value as a duration.
func Base64Decode ¶
Base64Decode decodes a base 64 string.
func ControlFor ¶
ControlFor returns just the input for a given struct field by name.
func DurationRound ¶
DurationRound rounds a duration value.
func DurationRoundMillis ¶
DurationRoundMillis rounds a duration value to milliseconds.
func DurationRoundSeconds ¶
DurationRoundSeconds rounds a duration value to seconds.
func FileExists ¶
FileExists returns if the file at a given path exists.
func First ¶
func First(collection interface{}) (interface{}, error)
First returns the first element of a collection.
func FormFor ¶
FormFor yields an html form input for a given value.
The value is reflected and the `form:"..."` struct tags are used to set options for individual fields.
func FormatFileSize ¶
FormatFileSize formats an int as a file size.
func FormatMoney ¶
FormatMoney returns a float as a formatted string rounded to two decimal places.
func FormatPct ¶
FormatPct formats a float as a percentage (it is multiplied by 100, then suffixed with '%')
func GenerateKey ¶
GenerateKey generates a key of a given size base 64 encoded.
func GenerateOrdinalNames ¶
GenerateOrdinalNames generates ordinal names by passing the index to a given formatter. The formatter should be in Sprintf format (i.e. using a '%d' token for where the index should go).
Example:
{{ generate_ordinal_names "worker-%d" 3 }} // [worker-0 worker-1 worker-2]
func IndentSpaces ¶
IndentSpaces indents a string by a given set of spaces.
func IndentTabs ¶
IndentTabs indents a string with a given number of tabs.
func Last ¶
func Last(collection interface{}) (interface{}, error)
Last returns the last element of a collection.
func ParseBool ¶
ParseBool attempts to parse a value as a bool. "truthy" values include "true", "1", "yes". "falsey" values include "false", "0", "no".
func ParseFloat64 ¶
ParseFloat64 parses a value as a float64.
func ParseInt64 ¶
ParseInt64 parses a value as an int64.
func ParseTimeUnix ¶
ParseTimeUnix returns a timestamp from a unix format.
func Quote ¶
Quote returns a string wrapped in " characters. It will trim space before and after, and only add quotes if they don't already exist.
func SequenceRange ¶
SequenceRange returns an array of ints from min to max, not including max. Given (0,5) as inputs, it would return [0,1,2,3,4]
func Slugify ¶
Slugify returns a slug format string. It replaces whitespace with `-` It path escapes any other characters.
func StripQuotes ¶
StripQuotes strips leading and trailing quotes.
func TimeFormat ¶
TimeFormat returns the time with a given format string.
func TimeFormatDateLong ¶
TimeFormatDateLong returns the short date for a timestamp.
func TimeFormatDateMonthDay ¶
TimeFormatDateMonthDay returns the month dat format for a timestamp. The format string is "1/2".
func TimeFormatDateShort ¶
TimeFormatDateShort returns the short date for a timestamp. The format string is "1/02/2006"
func TimeFormatDateShortRev ¶
TimeFormatDateShortRev returns the short date for a timestamp in YYYY/mm/dd format.
func TimeFormatKitchen ¶
TimeFormatTimeKitchen returns the kitchen format for a timestamp. The format string is "3:04PM".
func TimeFormatMedium ¶
TimeFormatTimeMedium returns the medium format for a timestamp. The format string is "1/02/2006 3:04:05 PM".
func TimeFormatRFC3339 ¶
TimeFormatRFC3339 returns the RFC3339 format for a timestamp.
func TimeFormatShort ¶
TimeFormatShort returns the short format for a timestamp. The format string is "1/02/2006 3:04:05 PM".
func TimeInLocation ¶
TimeInLocation returns the time in a given location by string. If the location is invalid, this will error.
func TimeInUTC ¶
TimeInUTC returns the time in a given location by string. If the location is invalid, this will error.
func TimeIsEpoch ¶
TimeIsEpoch returns if the time is the unix epoch time or not.
func TimeMillisecond ¶
TimeMillisecond returns the millisecond component of a timestamp.
func TimeMinute ¶
TimeMinute returns the minute component of a timestamp.
func TimeNowUTC ¶
TimeNowUTC returns the current time in the UTC timezone.
func TimeSecond ¶
TimeSecond returns the seconds component of a timestamp.
func TimeSince ¶
TimeSince returns the duration since a given timestamp. It is relative, meaning the value returned can be negative.
func TimeSinceUTC ¶
TimeSinceUTC returns the duration since a given timestamp in UTC. It is relative, meaning the value returned can be negative.
func TimeUnixNano ¶
TimeUnixNano returns the timetamp as nanoseconds from 1970-01-01.
func ToJSONPretty ¶
ToJSONPretty encodes an object as json with indentation.
func TrimPrefix ¶
TrimPrefix returns if a string has a given prefix.
func TrimSuffix ¶
TrimSuffix returns if a string has a given suffix.
func URLPort ¶
URLPort returns the url port. If none is explicitly specified, this will return empty string.
func WithURLHost ¶
WithURLHost returns the host of a url.
func WithURLPath ¶
WithURLPath returns the url path.
func WithURLPort ¶
WithURLPort sets the url port.
func WithURLQuery ¶
WithURLQuery returns a url query param.
func WithURLRawQuery ¶
WithURLRawQuery returns the url path.
Types ¶
type FormProvider ¶
FormProvider will shortcut reflection in the `FormFor` call.
type InputProvider ¶
InputProvider will shortcut reflection in the input generation step of a `FormFor` or `ControlFor` call.