Documentation ¶
Index ¶
- Variables
- func Add(a, b interface{}) (interface{}, error)
- func Args(args ...interface{}) map[string]interface{}
- func Divide(a, b interface{}) (interface{}, error)
- func ExternalURL(externalURL *url.URL) string
- func First(v queryResult) (*sample, error)
- func FormatDecimal(s string, n int) string
- func GraphLink(expr string) string
- func Humanize(s string) string
- func Humanize1024(s string) string
- func HumanizeDuration(s string) string
- func HumanizeDurationFloat64(v float64) string
- func HumanizeDurationInterface(i interface{}) string
- func HumanizePercentage(s string) string
- func HumanizePercentageH(s string) string
- func HumanizeTimestamp(i interface{}) (string, error)
- func Label(label string, s *sample) string
- func Match(pattern, s string) (bool, error)
- func Multiply(a, b interface{}) (interface{}, error)
- func Now() time.Time
- func ParseDuration(d string) (float64, error)
- func PathPrefix(externalURL *url.URL) string
- func Printf(format string, value interface{}) string
- func ReReplaceAll(pattern, repl, text string) string
- func ReplaceTemplateUseHtml(name string, templateText string, templateData any) string
- func ReplaceTemplateUseText(name string, templateText string, templateData any) string
- func SafeHtml(text string) template.HTML
- func SortByLabel(label string, v queryResult) queryResult
- func StrValue(s *sample) string
- func StripDomain(hostPort string) string
- func StripPort(hostPort string) string
- func Subtract(a, b interface{}) (interface{}, error)
- func TableLink(expr string) string
- func Timeformat(ts int64, pattern ...string) string
- func Timestamp(pattern ...string) string
- func Title(s string) string
- func ToFloat64(val interface{}) (float64, error)
- func ToLower(s string) string
- func ToString(v interface{}) string
- func ToTime(i interface{}) (*time.Time, error)
- func ToUpper(s string) string
- func Unescaped(str string) interface{}
- func Urlconvert(str string) interface{}
- func Value(s *sample) float64
Constants ¶
This section is empty.
Variables ¶
var TemplateFuncMap = template.FuncMap{ "escape": url.PathEscape, "unescaped": Unescaped, "urlconvert": Urlconvert, "timeformat": Timeformat, "timestamp": Timestamp, "args": Args, "reReplaceAll": ReReplaceAll, "match": regexp.MatchString, "toUpper": strings.ToUpper, "toLower": strings.ToLower, "contains": strings.Contains, "humanize": Humanize, "humanize1024": Humanize1024, "humanizeDuration": HumanizeDuration, "humanizeDurationInterface": HumanizeDurationInterface, "humanizePercentage": HumanizePercentage, "humanizePercentageH": HumanizePercentageH, "add": Add, "sub": Subtract, "mul": Multiply, "div": Divide, "now": Now, "toString": ToString, "formatDecimal": FormatDecimal, "first": First, "label": Label, "value": Value, "strvalue": StrValue, "safeHtml": SafeHtml, "title": Title, "graphLink": GraphLink, "tableLink": TableLink, "sortByLabel": SortByLabel, "stripPort": StripPort, "stripDomain": StripDomain, "toTime": ToTime, "pathPrefix": PathPrefix, "externalURL": ExternalURL, "parseDuration": ParseDuration, "printf": Printf, }
Functions ¶
func Divide ¶
func Divide(a, b interface{}) (interface{}, error)
Divide returns the division of b from a.
func ExternalURL ¶ added in v6.7.0
func FormatDecimal ¶ added in v6.0.2
func Humanize1024 ¶
func HumanizeDuration ¶
func HumanizeDurationFloat64 ¶
func HumanizeDurationInterface ¶
func HumanizeDurationInterface(i interface{}) string
func HumanizePercentage ¶
func HumanizePercentageH ¶
func HumanizeTimestamp ¶ added in v6.7.0
func Multiply ¶
func Multiply(a, b interface{}) (interface{}, error)
Multiply returns the product of a and b.
func ParseDuration ¶ added in v6.7.0
func PathPrefix ¶ added in v6.7.0
func ReReplaceAll ¶
func ReplaceTemplateUseHtml ¶ added in v6.4.0
ReplaceTemplateUseHtml replaces variables in a template string with values.
It accepts the following parameters:
- name: The name to use when parsing the template
- templateText: The template string containing variables to replace
- templateData: A struct containing fields to replace the variables
It parses the templateText into a template using template.New and template.Parse.
It executes the parsed template with templateData as the data, writing the result to a bytes.Buffer.
Any {{.Field}} variables in templateText are replaced with values from templateData.
If there are any errors parsing or executing the template, they are logged and the original templateText is returned.
The rendered template string is returned on success.
Example usage:
type Data struct { Name string } data := Data{"John"} output := ReplaceTemplateUseHtml("mytpl", "Hello {{.Name}}!", data)
func ReplaceTemplateUseText ¶ added in v6.4.0
func SortByLabel ¶ added in v6.7.0
func SortByLabel(label string, v queryResult) queryResult
func StripDomain ¶ added in v6.7.0
func Subtract ¶
func Subtract(a, b interface{}) (interface{}, error)
Subtract returns the difference of b from a.
func Timeformat ¶
func Urlconvert ¶
func Urlconvert(str string) interface{}
Types ¶
This section is empty.