type FuncMap … // builtins returns the FuncMap. // It is not a global variable so the linker can dead code eliminate // more when this isn't called. See golang.org/issue/36021. // TODO: revert this back to a global map once golang.org/issue/2559 is fixed. func builtins() FuncMap { … } var builtinFuncsOnce … // builtinFuncsOnce lazily computes & caches the builtinFuncs map. // TODO: revert this back to a global map once golang.org/issue/2559 is fixed. func builtinFuncs() map[string]reflect.Value { … } // createValueFuncs turns a FuncMap into a map[string]reflect.Value func createValueFuncs(funcMap FuncMap) map[string]reflect.Value { … } // addValueFuncs adds to values the functions in funcs, converting them to reflect.Values. func addValueFuncs(out map[string]reflect.Value, in FuncMap) { … } // addFuncs adds to values the functions in funcs. It does no checking of the input - // call addValueFuncs first. func addFuncs(out, in FuncMap) { … } // goodFunc reports whether the function or method has the right result signature. func goodFunc(name string, typ reflect.Type) error { … } // goodName reports whether the function name is a valid identifier. func goodName(name string) bool { … } // findFunction looks for a function in the template, and global map. func findFunction(name string, tmpl *Template) (v reflect.Value, isBuiltin, ok bool) { … } // prepareArg checks if value can be used as an argument of type argType, and // converts an invalid value to appropriate zero if possible. func prepareArg(value reflect.Value, argType reflect.Type) (reflect.Value, error) { … } func intLike(typ reflect.Kind) bool { … } // indexArg checks if a reflect.Value can be used as an index, and converts it to int if possible. func indexArg(index reflect.Value, cap int) (int, error) { … } // index returns the result of indexing its first argument by the following // arguments. Thus "index x 1 2 3" is, in Go syntax, x[1][2][3]. Each // indexed item must be a map, slice, or array. func index(item reflect.Value, indexes ...reflect.Value) (reflect.Value, error) { … } // slice returns the result of slicing its first argument by the remaining // arguments. Thus "slice x 1 2" is, in Go syntax, x[1:2], while "slice x" // is x[:], "slice x 1" is x[1:], and "slice x 1 2 3" is x[1:2:3]. The first // argument must be a string, slice, or array. func slice(item reflect.Value, indexes ...reflect.Value) (reflect.Value, error) { … } // length returns the length of the item, with an error if it has no defined length. func length(item reflect.Value) (int, error) { … } func emptyCall(fn reflect.Value, args ...reflect.Value) reflect.Value { … } // call returns the result of evaluating the first argument as a function. // The function must return 1 result, or 2 results, the second of which is an error. func call(name string, fn reflect.Value, args ...reflect.Value) (reflect.Value, error) { … } // safeCall runs fun.Call(args), and returns the resulting value and error, if // any. If the call panics, the panic value is returned as an error. func safeCall(fun reflect.Value, args []reflect.Value) (val reflect.Value, err error) { … } func truth(arg reflect.Value) bool { … } // and computes the Boolean AND of its arguments, returning // the first false argument it encounters, or the last argument. func and(arg0 reflect.Value, args ...reflect.Value) reflect.Value { … } // or computes the Boolean OR of its arguments, returning // the first true argument it encounters, or the last argument. func or(arg0 reflect.Value, args ...reflect.Value) reflect.Value { … } // not returns the Boolean negation of its argument. func not(arg reflect.Value) bool { … } var errBadComparisonType … var errBadComparison … var errNoComparison … type kind … const invalidKind … const boolKind … const complexKind … const intKind … const floatKind … const stringKind … const uintKind … func basicKind(v reflect.Value) (kind, error) { … } // isNil returns true if v is the zero reflect.Value, or nil of its type. func isNil(v reflect.Value) bool { … } // canCompare reports whether v1 and v2 are both the same kind, or one is nil. // Called only when dealing with nillable types, or there's about to be an error. func canCompare(v1, v2 reflect.Value) bool { … } // eq evaluates the comparison a == b || a == c || ... func eq(arg1 reflect.Value, arg2 ...reflect.Value) (bool, error) { … } // ne evaluates the comparison a != b. func ne(arg1, arg2 reflect.Value) (bool, error) { … } // lt evaluates the comparison a < b. func lt(arg1, arg2 reflect.Value) (bool, error) { … } // le evaluates the comparison <= b. func le(arg1, arg2 reflect.Value) (bool, error) { … } // gt evaluates the comparison a > b. func gt(arg1, arg2 reflect.Value) (bool, error) { … } // ge evaluates the comparison a >= b. func ge(arg1, arg2 reflect.Value) (bool, error) { … } var htmlQuot … var htmlApos … var htmlAmp … var htmlLt … var htmlGt … var htmlNull … // HTMLEscape writes to w the escaped HTML equivalent of the plain text data b. func HTMLEscape(w io.Writer, b []byte) { … } // HTMLEscapeString returns the escaped HTML equivalent of the plain text data s. func HTMLEscapeString(s string) string { … } // HTMLEscaper returns the escaped HTML equivalent of the textual // representation of its arguments. func HTMLEscaper(args ...any) string { … } var jsLowUni … var hex … var jsBackslash … var jsApos … var jsQuot … var jsLt … var jsGt … var jsAmp … var jsEq … // JSEscape writes to w the escaped JavaScript equivalent of the plain text data b. func JSEscape(w io.Writer, b []byte) { … } // JSEscapeString returns the escaped JavaScript equivalent of the plain text data s. func JSEscapeString(s string) string { … } func jsIsSpecial(r rune) bool { … } // JSEscaper returns the escaped JavaScript equivalent of the textual // representation of its arguments. func JSEscaper(args ...any) string { … } // URLQueryEscaper returns the escaped value of the textual representation of // its arguments in a form suitable for embedding in a URL query. func URLQueryEscaper(args ...any) string { … } // evalArgs formats the list of arguments into a string. It is therefore equivalent to // // fmt.Sprint(args...) // // except that each argument is indirected (if a pointer), as required, // using the same rules as the default string evaluation during template // execution. func evalArgs(args []any) string { … }