github.com/coveo/gotemplate@v2.7.7+incompatible/docs/functions_long.md (about) 1 {% include navigation.html %} 2 3 ## Functions 4 5 6 | 7 [Base go template functions](#base-go-template-functions) | 8 [Data Conversion](#data-conversion) | 9 [Data Manipulation](#data-manipulation) | 10 [Logging](#logging) | 11 [Mathematic Bit Operations](#mathematic-bit-operations) | 12 [Mathematic Fundamental](#mathematic-fundamental) | 13 [Mathematic Stats](#mathematic-stats) | 14 [Mathematic Trigonometry](#mathematic-trigonometry) | 15 [Mathematic Utilities](#mathematic-utilities) | 16 [Net](#net) | 17 [Operating systems functions](#operating-systems-functions) | 18 [Other utilities](#other-utilities) | 19 [Runtime](#runtime) | 20 [Sprig Cryptographic & Security](#sprig-cryptographic-&-security,-http://masterminds.github.io/sprig/crypto.html) | 21 [Sprig Date](#sprig-date,-http://masterminds.github.io/sprig/date.html) | 22 [Sprig Default](#sprig-default,-http://masterminds.github.io/sprig/defaults.html) | 23 [Sprig Dictionnary](#sprig-dictionnary,-http://masterminds.github.io/sprig/dicst.html) | 24 [Sprig Encoding](#sprig-encoding,-http://masterminds.github.io/sprig/encoding.html) | 25 [Sprig File Path](#sprig-file-path,-http://masterminds.github.io/sprig/paths.html) | 26 [Sprig Flow Control](#sprig-flow-control,-http://masterminds.github.io/sprig/flow_control.html) | 27 [Sprig General](#sprig-general,-http://masterminds.github.io/sprig/) | 28 [Sprig List](#sprig-list,-http://masterminds.github.io/sprig/lists.html) | 29 [Sprig Mathematics](#sprig-mathematics,-http://masterminds.github.io/sprig/math.html) | 30 [Sprig OS](#sprig-os,-http://masterminds.github.io/sprig/defaults.html) | 31 [Sprig Reflection](#sprig-reflection,-http://masterminds.github.io/sprig/reflection.html) | 32 [Sprig Regex](#sprig-regex,-http://masterminds.github.io/sprig/strings.html) | 33 [Sprig String Slice](#sprig-string-slice,-http://masterminds.github.io/sprig/string_slice.html) | 34 [Sprig Strings](#sprig-strings,-http://masterminds.github.io/sprig/strings.html) | 35 [Sprig Type Conversion](#sprig-type-conversion,-http://masterminds.github.io/sprig/conversion.html) | 36 [Sprig Version comparison](#sprig-version-comparison,-http://masterminds.github.io/sprig/semver.html) | 37 38 39 ### Base go template functions 40 41 ```go 42 // Returns the boolean AND of its arguments by returning the first empty argument or the last argument, that is, "and x y" behaves as "if x then y else x". All the arguments are evaluated. 43 func and(arg0 reflect.Value, args ...reflect.Value) reflect.Value 44 ``` 45 46 ```go 47 // Returns the result of calling the first argument, which must be a function, with the remaining arguments as parameters. Thus "call .X.Y 1 2" is, in Go notation, dot.X.Y(1, 2) where Y is a func-valued field, map entry, or the like. The first argument must be the result of an evaluation that yields a value of function type (as distinct from a predefined function such as print). The function must return either one or two result values, the second of which is of type error. If the arguments don't match the function or the returned error value is non-nil, execution stops. 48 func call(fn reflect.Value, args ...reflect.Value) reflect.Value, error) 49 ``` 50 51 ```go 52 // Returns the boolean truth of arg1 == arg2 53 func eq(arg1 reflect.Value, arg2 ...reflect.Value) (bool, error) 54 ``` 55 56 ```go 57 // Returns the boolean truth of arg1 >= arg2 58 func ge(arg1 reflect.Value, arg2 ...reflect.Value) (bool, error) 59 ``` 60 61 ```go 62 // Returns the boolean truth of arg1 > arg2 63 func gt(arg1 reflect.Value, arg2 ...reflect.Value) (bool, error) 64 ``` 65 66 ```go 67 // Returns the escaped HTML equivalent of the textual representation of its arguments. This function is unavailable in html/template, with a few exceptions. 68 func html(args ...interface{}) string 69 ``` 70 71 ```go 72 // 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. 73 func index(item reflect.Value, indices ...reflect.Value) (reflect.Value, error) 74 ``` 75 76 ```go 77 // Returns the escaped JavaScript equivalent of the textual representation of its arguments. 78 func js(args ...interface{}) string 79 ``` 80 81 ```go 82 // Returns the boolean truth of arg1 <= arg2 83 func le(arg1 reflect.Value, arg2 ...reflect.Value) (bool, error) 84 ``` 85 86 ```go 87 // Returns the integer length of its argument. 88 func len(item interface{}) (int, error) 89 ``` 90 91 ```go 92 // Returns the boolean truth of arg1 < arg2 93 func lt(arg1 reflect.Value, arg2 ...reflect.Value) (bool, error) 94 ``` 95 96 ```go 97 // Returns the boolean truth of arg1 != arg2 98 func ne(arg1 reflect.Value, arg2 ...reflect.Value) (bool, error) 99 ``` 100 101 ```go 102 // Returns the boolean negation of its single argument. 103 func not(not(arg reflect.Value) bool 104 ``` 105 106 ```go 107 // Returns the boolean OR of its arguments by returning the first non-empty argument or the last argument, that is, "or x y" behaves as "if x then x else y". All the arguments are evaluated. 108 func or(or(arg0 reflect.Value, args ...reflect.Value) reflect.Value 109 ``` 110 111 ```go 112 // An alias for fmt.Sprint 113 func print(args ...interface{}) string 114 ``` 115 116 ```go 117 // An alias for fmt.Sprintf 118 func printf(format string, args ...interface{}) string 119 ``` 120 121 ```go 122 // An alias for fmt.Sprintln 123 func println(args ...interface{}) string 124 ``` 125 126 ```go 127 // Returns the escaped value of the textual representation of its arguments in a form suitable for embedding in a URL query. This function is unavailable in html/template, with a few exceptions. 128 func urlquery(args ...interface{}) string 129 ``` 130 ### Data Conversion 131 132 ```go 133 // Tries to convert the supplied data string into data structure (Go spec). It will try to convert HCL, YAML and JSON format. If context is omitted, default context is used. 134 // Aliases: DATA, fromData, fromDATA 135 func data(data interface{}, context ...interface{}) interface{}, error 136 ``` 137 138 ```go 139 // Converts the supplied hcl string into data structure (Go spec). If context is omitted, default context is used. 140 // Aliases: HCL, fromHcl, fromHCL, tfvars, fromTFVars, TFVARS, fromTFVARS 141 func hcl(hcl interface{}, context ...interface{}) interface{}, error 142 ``` 143 144 ```go 145 // Converts the supplied json string into data structure (Go spec). If context is omitted, default context is used. 146 // Aliases: JSON, fromJson, fromJSON 147 func json(json interface{}, context ...interface{}) interface{}, error 148 ``` 149 150 ```go 151 // Converts the supplied value to bash compatible representation. 152 func toBash(value interface{}) string 153 ``` 154 155 ```go 156 // Converts the supplied value to compact HCL representation. 157 // Aliases: toHCL 158 func toHcl(value interface{}) string, error 159 ``` 160 161 ```go 162 // Converts the supplied value to compact HCL representation used inside outer HCL definition. 163 // Aliases: toInternalHCL, toIHCL, toIHcl 164 func toInternalHcl(value interface{}) string, error 165 ``` 166 167 ```go 168 // Converts the supplied value to compact JSON representation. 169 // Aliases: toJSON 170 func toJson(value interface{}) string, error 171 ``` 172 173 ```go 174 // Converts the supplied value to pretty HCL representation. 175 // Aliases: toPrettyHCL 176 func toPrettyHcl(value interface{}) string, error 177 ``` 178 179 ```go 180 // Converts the supplied value to pretty JSON representation. 181 // Aliases: toPrettyJSON 182 func toPrettyJson(value interface{}) string, error 183 ``` 184 185 ```go 186 // Converts the supplied value to pretty HCL representation (without multiple map declarations). 187 func toPrettyTFVars(value interface{}) string, error 188 ``` 189 190 ```go 191 // Converts the supplied value to compact quoted HCL representation. 192 // Aliases: toQuotedHCL 193 func toQuotedHcl(value interface{}) string, error 194 ``` 195 196 ```go 197 // Converts the supplied value to compact quoted JSON representation. 198 // Aliases: toQuotedJSON 199 func toQuotedJson(value interface{}) string, error 200 ``` 201 202 ```go 203 // Converts the supplied value to compact HCL representation (without multiple map declarations). 204 func toQuotedTFVars(value interface{}) string, error 205 ``` 206 207 ```go 208 // Converts the supplied value to compact HCL representation (without multiple map declarations). 209 func toTFVars(value interface{}) string, error 210 ``` 211 212 ```go 213 // Converts the supplied value to YAML representation. 214 // Aliases: toYAML 215 func toYaml(value interface{}) string, error 216 ``` 217 218 ```go 219 // Converts the supplied yaml string into data structure (Go spec). If context is omitted, default context is used. 220 // Aliases: YAML, fromYaml, fromYAML 221 func yaml(yaml interface{}, context ...interface{}) interface{}, error 222 ``` 223 ### Data Manipulation 224 225 ```go 226 // Returns a String class object that allows invoking standard string operations as method. 227 func String(value interface{}) String 228 ``` 229 230 ```go 231 // Append new items to an existing list, creating a new list. 232 // Aliases: push 233 func append(list interface{}, elements ...interface{}) IGenericList, error 234 ``` 235 236 ```go 237 // Ensures that the supplied argument is an array (if it is already an array/slice, there is no change, if not, the argument is replaced by []interface{} with a single value). 238 func array(value interface{}) interface{} 239 ``` 240 241 ```go 242 // Converts the `string` into boolean value (`string` must be `True`, `true`, `TRUE`, `1` or `False`, `false`, `FALSE`, `0`) 243 func bool(str string) bool, error 244 ``` 245 246 ```go 247 // Returns the character corresponging to the supplied integer value 248 func char(value interface{}) interface{}, error 249 ``` 250 251 ```go 252 // Test to see if a list has a particular elements. 253 // Aliases: has 254 func contains(list interface{}, elements ...interface{}) bool, error 255 ``` 256 257 ```go 258 // Returns the content of a single element map (used to retrieve content in a declaration like `value "name" { a = 1 b = 3}`) 259 func content(keymap interface{}) interface{}, error 260 ``` 261 262 ```go 263 // Returns a new dictionary from a list of pairs (key, value). 264 // Aliases: dictionary 265 func dict(args ...interface{}) IDictionary, error 266 ``` 267 268 ```go 269 // Extracts values from a slice or a map, indexes could be either integers for slice or strings for maps 270 func extract(source interface{}, indexes ...interface{}) interface{}, error 271 ``` 272 273 ```go 274 // Returns the value associated with the supplied map, key and map could be inverted for convenience (i.e. when using piping mode) 275 func get(map interface{}, key interface{}, default ...interface{}) interface{}, error 276 ``` 277 278 ```go 279 // Returns true if the dictionary contains the specified key. 280 func hasKey(dictionary interface{}, key interface{}) interface{}, error 281 ``` 282 283 ```go 284 // Returns but the last element. 285 func initial(list interface{}) interface{}, error 286 ``` 287 288 ```go 289 // Returns a list that is the intersection of the list and all arguments (removing duplicates). 290 func intersect(list interface{}, elements ...interface{}) IGenericList, error 291 ``` 292 293 ```go 294 // Returns true if the supplied value is nil. 295 // Aliases: isNull 296 func isNil(arg1 interface{}) bool 297 ``` 298 299 ```go 300 // Returns true if the supplied value is not nil. 301 func isSet(arg1 interface{}) bool 302 ``` 303 304 ```go 305 // Returns true if the supplied value is false, 0, nil or empty. 306 // Aliases: isEmpty 307 func isZero(arg1 interface{}) bool 308 ``` 309 310 ```go 311 // Returns the key name of a single element map (used to retrieve name in a declaration like `value "name" { a = 1 b = 3}`) 312 func key(value interface{}) interface{}, error 313 ``` 314 315 ```go 316 // Returns a list of all of the keys in a dict (in alphabetical order). 317 func keys(dictionary IDictionary) IGenericList 318 ``` 319 320 ```go 321 // Returns the number of actual character in a string. 322 // Aliases: nbChars 323 func lenc(str string) int 324 ``` 325 326 ```go 327 // Returns a generic list from the supplied arguments. 328 // Aliases: tuple 329 func list(args ...interface{}) IGenericList 330 ``` 331 332 ```go 333 // Merges two or more dictionaries into one, giving precedence to the dest dictionary. 334 func merge(destination IDictionary, sources IDictionary, args ...IDictionary) IDictionary 335 ``` 336 337 ```go 338 // Returns a new dict with all the keys that do not match the given keys. 339 func omit(dict IDictionary, keys interface{}, args ...interface{}) IDictionary 340 ``` 341 342 ```go 343 // Selects just the given keys out of a dictionary, creating a new dict. 344 func pick(dict IDictionary, keys ...interface{}) IDictionary 345 ``` 346 347 ```go 348 // Same as pick, but returns an error message if there are intruders in supplied dictionary. 349 func pickv(dict IDictionary, message string, keys interface{}, args ...interface{}) interface{}, error 350 ``` 351 352 ```go 353 // Extracts a list of values matching the supplied key from a list of dictionary. 354 func pluck(key interface{}, dictionaries ...IDictionary) IGenericList 355 ``` 356 357 ```go 358 // Push elements onto the front of a list, creating a new list. 359 func prepend(list interface{}, elements ...interface{}) IGenericList, error 360 ``` 361 362 ```go 363 // Gets the tail of the list (everything but the first item) 364 func rest(list interface{}) interface{}, error 365 ``` 366 367 ```go 368 // Produces a new list with the reversed elements of the given list. 369 func reverse(list interface{}) IGenericList, error 370 ``` 371 372 ```go 373 // Returns the element at index position or default if index is outside bounds. 374 func safeIndex(value interface{}, index int, default interface{}) interface{}, error 375 ``` 376 377 ```go 378 // Adds the value to the supplied map using key as identifier. 379 func set(dict interface{}, key interface{}, value interface{}) string, error 380 ``` 381 382 ```go 383 // Returns a slice of the supplied object (equivalent to object[from:to]). 384 func slice(value interface{}, args ...interface{}) interface{}, error 385 ``` 386 387 ```go 388 // Converts the supplied value into its string representation. 389 func string(value interface{}) string 390 ``` 391 392 ```go 393 // Returns the default value if value is not set, alias `undef` (differs from Sprig `default` function as empty value such as 0, false, "" are not considered as unset). 394 // Aliases: ifUndef 395 func undef(default interface{}, values ...interface{}) interface{} 396 ``` 397 398 ```go 399 // Returns a list that is the union of the list and all arguments (removing duplicates). 400 func union(list interface{}, elements ...interface{}) IGenericList, error 401 ``` 402 403 ```go 404 // Generates a list with all of the duplicates removed. 405 // Aliases: uniq 406 func unique(list interface{}) IGenericList, error 407 ``` 408 409 ```go 410 // Removes an element from a dictionary. 411 // Aliases: delete, remove 412 func unset(dictionary interface{}, key interface{}) string, error 413 ``` 414 415 ```go 416 func values(arg1 IDictionary) IGenericList 417 ``` 418 419 ```go 420 // Filters items out of a list. 421 func without(list interface{}, elements ...interface{}) IGenericList, error 422 ``` 423 ### Logging 424 425 ```go 426 // Logs a message using CRITICAL as log level (0). 427 // Aliases: criticalf 428 func critical(args ...interface{}) string 429 ``` 430 431 ```go 432 // Logs a message using DEBUG as log level (5). 433 // Aliases: debugf 434 func debug(args ...interface{}) string 435 ``` 436 437 ```go 438 // Logs a message using ERROR as log level (1). 439 // Aliases: errorf 440 func error(args ...interface{}) string 441 ``` 442 443 ```go 444 // Equivalents to critical followed by a call to os.Exit(1). 445 // Aliases: fatalf 446 func fatal(args ...interface{}) string 447 ``` 448 449 ```go 450 // Logs a message using INFO as log level (4). 451 // Aliases: infof 452 func info(args ...interface{}) string 453 ``` 454 455 ```go 456 // Logs a message using NOTICE as log level (3). 457 // Aliases: noticef 458 func notice(args ...interface{}) string 459 ``` 460 461 ```go 462 // Equivalents to critical followed by a call to panic. 463 // Aliases: panicf 464 func panic(args ...interface{}) string 465 ``` 466 467 ```go 468 // Logs a message using WARNING as log level (2). 469 // Aliases: warn, warnf, warningf 470 func warning(args ...interface{}) string 471 ``` 472 ### Mathematic Bit Operations 473 474 ```go 475 // Aliases: bitwiseAND 476 func band(arg1 interface{}, arg2 interface{}, args ...interface{}) interface{}, error 477 ``` 478 479 ```go 480 // Aliases: bitwiseClear 481 func bclear(arg1 interface{}, arg2 interface{}, args ...interface{}) interface{}, error 482 ``` 483 484 ```go 485 // Aliases: bitwiseOR 486 func bor(arg1 interface{}, arg2 interface{}, args ...interface{}) interface{}, error 487 ``` 488 489 ```go 490 // Aliases: bitwiseXOR 491 func bxor(arg1 interface{}, arg2 interface{}, args ...interface{}) interface{}, error 492 ``` 493 494 ```go 495 // Aliases: leftShift 496 func lshift(arg1 interface{}, arg2 interface{}) interface{}, error 497 ``` 498 499 ```go 500 // Aliases: rightShift 501 func rshift(arg1 interface{}, arg2 interface{}) interface{}, error 502 ``` 503 ### Mathematic Fundamental 504 505 ```go 506 // Aliases: sum 507 func add(arg1 interface{}, args ...interface{}) interface{}, error 508 ``` 509 510 ```go 511 // Returns the cube root of x. 512 // Special cases are: 513 // cbrt(±0) = ±0 514 // cbrt(±Inf) = ±Inf 515 // cbrt(NaN) = NaN 516 func cbrt(x interface{}) interface{}, error 517 ``` 518 519 ```go 520 // Returns the least integer value greater than or equal to x. 521 // Special cases are: 522 // ceil(±0) = ±0 523 // ceil(±Inf) = ±Inf 524 // ceil(NaN) = NaN 525 // Aliases: roundUp, roundup 526 func ceil(x interface{}) interface{}, error 527 ``` 528 529 ```go 530 // Returns the maximum of x-y or 0. 531 // Special cases are: 532 // dim(+Inf, +Inf) = NaN 533 // dim(-Inf, -Inf) = NaN 534 // dim(x, NaN) = dim(NaN, x) = NaN 535 func dim(x interface{}, y interface{}) interface{}, error 536 ``` 537 538 ```go 539 // Aliases: divide, quotient 540 func div(arg1 interface{}, arg2 interface{}) interface{}, error 541 ``` 542 543 ```go 544 // Returns e**x, the base-e exponential of x. 545 // Special cases are: 546 // exp(+Inf) = +Inf 547 // exp(NaN) = NaN 548 // Very large values overflow to 0 or +Inf. Very small values underflow to 1. 549 // Aliases: exponent 550 func exp(x interface{}) interface{}, error 551 ``` 552 553 ```go 554 // Returns 2**x, the base-2 exponential of x. 555 // Special cases are the same as exp. 556 // Aliases: exponent2 557 func exp2(x interface{}) interface{}, error 558 ``` 559 560 ```go 561 // Returns e**x - 1, the base-e exponential of x minus 1. It is more 562 // accurate than exp(x) - 1 when x is near zero. 563 // Special cases are: 564 // expm1(+Inf) = +Inf 565 // expm1(-Inf) = -1 566 // expm1(NaN) = NaN 567 // Very large values overflow to -1 or +Inf 568 func expm1(x interface{}) interface{}, error 569 ``` 570 571 ```go 572 // Returns the greatest integer value less than or equal to x. 573 // Special cases are: 574 // floor(±0) = ±0 575 // floor(±Inf) = ±Inf 576 // floor(NaN) = NaN 577 // Aliases: roundDown, rounddown, int, integer 578 func floor(x interface{}) interface{}, error 579 ``` 580 581 ```go 582 // Returns the floating-point remainder of x/y. The magnitude of the result is less than y and its sign agrees with that of x. 583 // Special cases are: 584 // mod(±Inf, y) = NaN 585 // mod(NaN, y) = NaN 586 // mod(x, 0) = NaN 587 // mod(x, ±Inf) = x 588 // mod(x, NaN) = NaN 589 // Aliases: modulo 590 func mod(x interface{}, y interface{}) interface{}, error 591 ``` 592 593 ```go 594 // Returns integer and fractional floating-point numbers that sum to f. Both values have the same sign as f. 595 // Special cases are: 596 // modf(±Inf) = ±Inf, NaN 597 // modf(NaN) = NaN, NaN 598 func modf(f interface{}) interface{}, error 599 ``` 600 601 ```go 602 // Aliases: multiply, prod, product 603 func mul(arg1 interface{}, args ...interface{}) interface{}, error 604 ``` 605 606 ```go 607 // Returns x**y, the base-x exponential of y. 608 // Special cases are (in order): 609 // pow(x, ±0) = 1 for any x 610 // pow(1, y) = 1 for any y 611 // pow(x, 1) = x for any x 612 // pow(NaN, y) = NaN 613 // pow(x, NaN) = NaN 614 // pow(±0, y) = ±Inf for y an odd integer < 0 615 // pow(±0, -Inf) = +Inf 616 // pow(±0, +Inf) = +0 617 // pow(±0, y) = +Inf for finite y < 0 and not an odd integer 618 // pow(±0, y) = ±0 for y an odd integer > 0 619 // pow(±0, y) = +0 for finite y > 0 and not an odd integer 620 // pow(-1, ±Inf) = 1 621 // pow(x, +Inf) = +Inf for |x| > 1 622 // pow(x, -Inf) = +0 for |x| > 1 623 // pow(x, +Inf) = +0 for |x| < 1 624 // pow(x, -Inf) = +Inf for |x| < 1 625 // pow(+Inf, y) = +Inf for y > 0 626 // pow(+Inf, y) = +0 for y < 0 627 // pow(-Inf, y) = Pow(-0, -y) 628 // pow(x, y) = NaN for finite x < 0 and finite non-integer y 629 // Aliases: power 630 func pow(x interface{}, y interface{}) interface{}, error 631 ``` 632 633 ```go 634 // Returns 10**n, the base-10 exponential of n. 635 // Special cases are: 636 // pow10(n) =0 for n < -323 637 // pow10(n) = +Inf for n > 308 638 // Aliases: power10 639 func pow10(n interface{}) interface{}, error 640 ``` 641 642 ```go 643 // Returns the IEEE 754 floating-point remainder of x/y. 644 // Special cases are: 645 // rem(±Inf, y) = NaN 646 // rem(NaN, y) = NaN 647 // rem(x, 0) = NaN 648 // rem(x, ±Inf) = x 649 // rem(x, NaN) = NaN 650 // Aliases: remainder 651 func rem(arg1 interface{}, arg2 interface{}) interface{}, error 652 ``` 653 654 ```go 655 // Aliases: subtract 656 func sub(arg1 interface{}, arg2 interface{}) interface{}, error 657 ``` 658 659 ```go 660 // Returns the integer value of x. 661 // Special cases are: 662 // trunc(±0) = ±0 663 // trunc(±Inf) = ±Inf 664 // trunc(NaN) = NaN 665 // Aliases: truncate 666 func trunc(x interface{}) interface{}, error 667 ``` 668 ### Mathematic Stats 669 670 ```go 671 // Aliases: average 672 func avg(arg1 interface{}, args ...interface{}) interface{}, error 673 ``` 674 675 ```go 676 // Returns the larger of x or y. 677 // Special cases are: 678 // max(x, +Inf) = max(+Inf, x) = +Inf 679 // max(x, NaN) = max(NaN, x) = NaN 680 // max(+0, ±0) = max(±0, +0) = +0 681 // max(-0, -0) = -0 682 // Aliases: maximum, biggest 683 func max(x ...interface{}) interface{} 684 ``` 685 686 ```go 687 // Returns the smaller of x or y. 688 // Special cases are: 689 // min(x, -Inf) = min(-Inf, x) = -Inf 690 // min(x, NaN) = min(NaN, x) = NaN 691 // min(-0, ±0) = min(±0, -0) = -0 692 // Aliases: minimum, smallest 693 func min(x ...interface{}) interface{} 694 ``` 695 ### Mathematic Trigonometry 696 697 ```go 698 // Returns the arccosine, in radians, of x. 699 // Special case is: 700 // acos(x) = NaN if x < -1 or x > 1 701 // Aliases: arcCosine, arcCosinus 702 func acos(x interface{}) interface{}, error 703 ``` 704 705 ```go 706 // Returns the inverse hyperbolic cosine of x. 707 // Special cases are: 708 // acosh(+Inf) = +Inf 709 // acosh(x) = NaN if x < 1 710 // acosh(NaN) = NaN 711 // Aliases: arcHyperbolicCosine, arcHyperbolicCosinus 712 func acosh(x interface{}) interface{}, error 713 ``` 714 715 ```go 716 // Returns the arcsine, in radians, of x. 717 // Special cases are: 718 // asin(±0) = ±0 719 // asin(x) = NaN if x < -1 or x > 1 720 // Aliases: arcSine, arcSinus 721 func asin(x interface{}) interface{}, error 722 ``` 723 724 ```go 725 // Returns the inverse hyperbolic sine of x. 726 // Special cases are: 727 // asinh(±0) = ±0 728 // asinh(±Inf) = ±Inf 729 // asinh(NaN) = NaN 730 // Aliases: arcHyperbolicSine, arcHyperbolicSinus 731 func asinh(x interface{}) interface{}, error 732 ``` 733 734 ```go 735 // Returns the arctangent, in radians, of x. 736 // Special cases are: 737 // atan(±0) = ±0 738 // atan(±Inf) = ±Pi/2 739 // Aliases: arcTangent 740 func atan(x interface{}) interface{}, error 741 ``` 742 743 ```go 744 // Returns the arc tangent of y/x, using the signs of the two to determine the quadrant of the return value. 745 // Special cases are (in order): 746 // atan2(y, NaN) = NaN 747 // atan2(NaN, x) = NaN 748 // atan2(+0, x>=0) = +0 749 // atan2(-0, x>=0) = -0 750 // atan2(+0, x<=-0) = +Pi 751 // atan2(-0, x<=-0) = -Pi 752 // atan2(y>0, 0) = +Pi/2 753 // atan2(y<0, 0) = -Pi/2 754 // atan2(+Inf, +Inf) = +Pi/4 755 // atan2(-Inf, +Inf) = -Pi/4 756 // atan2(+Inf, -Inf) = 3Pi/4 757 // atan2(-Inf, -Inf) = -3Pi/4 758 // atan2(y, +Inf) = 0 759 // atan2(y>0, -Inf) = +Pi 760 // atan2(y<0, -Inf) = -Pi 761 // atan2(+Inf, x) = +Pi/2 762 // atan2(-Inf, x) = -Pi/2 763 // Aliases: arcTangent2 764 func atan2(x interface{}, y interface{}) interface{}, error 765 ``` 766 767 ```go 768 // Returns the inverse hyperbolic tangent of x. 769 // Special cases are: 770 // atanh(1) = +Inf 771 // atanh(±0) = ±0 772 // atanh(-1) = -Inf 773 // atanh(x) = NaN if x < -1 or x > 1 774 // atanh(NaN) = NaN 775 // Aliases: arcHyperbolicTangent 776 func atanh(x interface{}) interface{}, error 777 ``` 778 779 ```go 780 // Returns the cosine of the radian argument x. 781 // Special cases are: 782 // cos(±Inf) = NaN 783 // cos(NaN) = NaN 784 // Aliases: cosine, cosinus 785 func cos(x interface{}) interface{}, error 786 ``` 787 788 ```go 789 // Returns the hyperbolic cosine of x. 790 // Special cases are: 791 // cosh(±0) = 1 792 // cosh(±Inf) = +Inf 793 // cosh(NaN) = NaN 794 // Aliases: hyperbolicCosine, hyperbolicCosinus 795 func cosh(x interface{}) interface{}, error 796 ``` 797 798 ```go 799 // Aliases: degree 800 func deg(arg1 interface{}) interface{}, error 801 ``` 802 803 ```go 804 // Returns the binary exponent of x as an integer. 805 // Special cases are: 806 // ilogb(±Inf) = MaxInt32 807 // ilogb(0) = MinInt32 808 // ilogb(NaN) = MaxInt32 809 func ilogb(x interface{}) interface{}, error 810 ``` 811 812 ```go 813 // Returns the order-zero Bessel function of the first kind. 814 // Special cases are: 815 // j0(±Inf) = 0 816 // j0(0) = 1 817 // j0(NaN) = NaN 818 // Aliases: firstBessel0 819 func j0(x interface{}) interface{}, error 820 ``` 821 822 ```go 823 // Returns the order-one Bessel function of the first kind. 824 // Special cases are: 825 // j1(±Inf) = 0 826 // j1(NaN) = NaN 827 // Aliases: firstBessel1 828 func j1(x interface{}) interface{}, error 829 ``` 830 831 ```go 832 // Returns the order-n Bessel function of the first kind. 833 // Special cases are: 834 // jn(n, ±Inf) = 0 835 // jn(n, NaN) = NaN 836 // Aliases: firstBesselN 837 func jn(n interface{}, x interface{}) interface{}, error 838 ``` 839 840 ```go 841 // Returns the natural logarithm of x. 842 // Special cases are: 843 // log(+Inf) = +Inf 844 // log(0) = -Inf 845 // log(x < 0) = NaN 846 // log(NaN) = NaN 847 func log(x interface{}) interface{}, error 848 ``` 849 850 ```go 851 // Returns the decimal logarithm of x. The special cases are the same as for log. 852 func log10(x interface{}) interface{}, error 853 ``` 854 855 ```go 856 // Returns the natural logarithm of 1 plus its argument x. It is more accurate than log(1 + x) when x is near zero. 857 // Special cases are: 858 // log1p(+Inf) = +Inf 859 // log1p(±0) = ±0 860 // log1p(-1) = -Inf 861 // log1p(x < -1) = NaN 862 // log1p(NaN) = NaN 863 func log1p(x interface{}) interface{}, error 864 ``` 865 866 ```go 867 // Returns the binary logarithm of x. The special cases are the same as for log. 868 func log2(x interface{}) interface{}, error 869 ``` 870 871 ```go 872 // Returns the binary exponent of x. 873 // Special cases are: 874 // logb(±Inf) = +Inf 875 // logb(0) = -Inf 876 // logb(NaN) = NaN 877 func logb(x interface{}) interface{}, error 878 ``` 879 880 ```go 881 // Aliases: radian 882 func rad(arg1 interface{}) interface{}, error 883 ``` 884 885 ```go 886 // Returns the sine of the radian argument x. 887 // Special cases are: 888 // sin(±0) = ±0 889 // sin(±Inf) = NaN 890 // sin(NaN) = NaN 891 // Aliases: sine, sinus 892 func sin(x interface{}) interface{}, error 893 ``` 894 895 ```go 896 // Returns Sin(x), Cos(x). 897 // Special cases are: 898 // sincos(±0) = ±0, 1 899 // sincos(±Inf) = NaN, NaN 900 // sincos(NaN) = NaN, NaN 901 // Aliases: sineCosine, sinusCosinus 902 func sincos(x interface{}) interface{}, error 903 ``` 904 905 ```go 906 // Returns the hyperbolic sine of x. 907 // Special cases are: 908 // sinh(±0) = ±0 909 // sinh(±Inf) = ±Inf 910 // sinh(NaN) = NaN 911 // Aliases: hyperbolicSine, hyperbolicSinus 912 func sinh(x interface{}) interface{}, error 913 ``` 914 915 ```go 916 // Returns the tangent of the radian argument x. 917 // Special cases are: 918 // tan(±0) = ±0 919 // tan(±Inf) = NaN 920 // tan(NaN) = NaN 921 // Aliases: tangent 922 func tan(x interface{}) interface{}, error 923 ``` 924 925 ```go 926 // Returns the hyperbolic tangent of x. 927 // Special cases are: 928 // tanh(±0) = ±0 929 // tanh(±Inf) = ±1 930 // tanh(NaN) = NaN 931 // Aliases: hyperbolicTangent 932 func tanh(x interface{}) interface{}, error 933 ``` 934 935 ```go 936 // Returns the order-zero Bessel function of the second kind. 937 // Special cases are: 938 // y0(+Inf) = 0 939 // y0(0) = -Inf 940 // y0(x < 0) = NaN 941 // y0(NaN) = NaN 942 // Aliases: secondBessel0 943 func y0(x interface{}) interface{}, error 944 ``` 945 946 ```go 947 // Returns the order-one Bessel function of the second kind. 948 // Special cases are: 949 // y1(+Inf) = 0 950 // y1(0) = -Inf 951 // y1(x < 0) = NaN 952 // y1(NaN) = NaN 953 // Aliases: secondBessel1 954 func y1(x interface{}) interface{}, error 955 ``` 956 957 ```go 958 // Returns the order-n Bessel function of the second kind. 959 // Special cases are: 960 // yn(n, +Inf) = 0 961 // yn(n ≥ 0, 0) = -Inf 962 // yn(n < 0, 0) = +Inf if n is odd, -Inf if n is even 963 // yn(n, x < 0) = NaN 964 // yn(n, NaN) = NaN 965 // Aliases: secondBesselN 966 func yn(n interface{}, x interface{}) interface{}, error 967 ``` 968 ### Mathematic Utilities 969 970 ```go 971 // Returns the absolute value of x. 972 // Special cases are: 973 // abs(±Inf) = +Inf 974 // abs(NaN) = NaN 975 // Aliases: absolute 976 func abs(x interface{}) interface{}, error 977 ``` 978 979 ```go 980 // Aliases: decimal 981 func dec(arg1 interface{}) interface{}, error 982 ``` 983 984 ```go 985 // Breaks f into a normalized fraction and an integral power of two. Returns frac and exp satisfying f == frac × 2**exp, with the absolute value of frac in the interval [½, 1). 986 // Special cases are: 987 // frexp(±0) = ±0, 0 988 // frexp(±Inf) = ±Inf, 0 989 // frexp(NaN) = NaN, 0 990 func frexp(f interface{}) interface{}, error 991 ``` 992 993 ```go 994 // Returns the Gamma function of x. 995 // Special cases are: 996 // gamma(+Inf) = +Inf 997 // gamma(+0) = +Inf 998 // gamma(-0) = -Inf 999 // gamma(x) = NaN for integer x < 0 1000 // gamma(-Inf) = NaN 1001 // gamma(NaN) = NaN 1002 func gamma(x interface{}) interface{}, error 1003 ``` 1004 1005 ```go 1006 // Aliases: hexa, hexaDecimal 1007 func hex(arg1 interface{}) interface{}, error 1008 ``` 1009 1010 ```go 1011 // Returns Sqrt(p*p + q*q), taking care to avoid unnecessary overflow and underflow. 1012 // Special cases are: 1013 // hypot(±Inf, q) = +Inf 1014 // hypot(p, ±Inf) = +Inf 1015 // hypot(NaN, q) = NaN 1016 // hypot(p, NaN) = NaN 1017 // Aliases: hypotenuse 1018 func hypot(p interface{}, q interface{}) interface{}, error 1019 ``` 1020 1021 ```go 1022 // Reports whether f is an infinity, according to sign. If sign > 0, isInf reports whether f is positive infinity. If sign < 0, IsInf reports whether f is negative infinity. If sign == 0, IsInf reports whether f is either infinity 1023 // Aliases: isInfinity 1024 func isInf(f interface{}, arg2 interface{}) interface{}, error 1025 ``` 1026 1027 ```go 1028 // Reports whether f is an IEEE 754 'not-a-number' value 1029 func isNaN(f interface{}) interface{}, error 1030 ``` 1031 1032 ```go 1033 // Ldexp is the inverse of Frexp. Returns frac × 2**exp. 1034 // Special cases are: 1035 // ldexp(±0, exp) = ±0 1036 // ldexp(±Inf, exp) = ±Inf 1037 // ldexp(NaN, exp) = NaN 1038 func ldexp(frac interface{}, exp interface{}) interface{}, error 1039 ``` 1040 1041 ```go 1042 // Returns the natural logarithm and sign (-1 or +1) of Gamma(x). 1043 // Special cases are: 1044 // lgamma(+Inf) = +Inf 1045 // lgamma(0) = +Inf 1046 // lgamma(-integer) = +Inf 1047 // lgamma(-Inf) = -Inf 1048 // lgamma(NaN) = NaN 1049 func lgamma(x interface{}) interface{}, error 1050 ``` 1051 1052 ```go 1053 // Returns the next representable float64 value after x towards y. 1054 // Special cases are: 1055 // Nextafter(x, x) = x 1056 // Nextafter(NaN, y) = NaN 1057 // Nextafter(x, NaN) = NaN 1058 func nextAfter(arg1 interface{}, arg2 interface{}) interface{}, error 1059 ``` 1060 1061 ```go 1062 func signBit(arg1 interface{}, arg2 interface{}) interface{}, error 1063 ``` 1064 1065 ```go 1066 // Returns the square root of x. 1067 // Special cases are: 1068 // sqrt(+Inf) = +Inf 1069 // sqrt(±0) = ±0 1070 // sqrt(x < 0) = NaN 1071 // sqrt(NaN) = NaN 1072 // Aliases: squareRoot 1073 func sqrt(x interface{}) interface{}, error 1074 ``` 1075 1076 ```go 1077 func to(args ...interface{}) interface{}, error 1078 ``` 1079 1080 ```go 1081 func until(args ...interface{}) interface{}, error 1082 ``` 1083 ### Net 1084 1085 ```go 1086 // Returns http document returned by supplied URL. 1087 // Aliases: httpDocument, curl 1088 func httpDoc(url interface{}) interface{}, error 1089 ``` 1090 1091 ```go 1092 // Returns http get response from supplied URL. 1093 func httpGet(url interface{}) *http.Response, error 1094 ``` 1095 ### Operating systems functions 1096 1097 ```go 1098 // Returns a colored string that highlight differences between supplied texts. 1099 // Aliases: difference 1100 func diff(text1 interface{}, text2 interface{}) interface{} 1101 ``` 1102 1103 ```go 1104 // Determines if a file exists or not. 1105 // Aliases: fileExists, isExist 1106 func exists(filename interface{}) bool, error 1107 ``` 1108 1109 ```go 1110 // Returns the expanded list of supplied arguments (expand *[]? on filename). 1111 // Aliases: expand 1112 func glob(args ...interface{}) IGenericList 1113 ``` 1114 1115 ```go 1116 // Returns the current user group information (user.Group object). 1117 // Aliases: userGroup 1118 func group() *user.Group, error 1119 ``` 1120 1121 ```go 1122 // Returns the home directory of the current user. 1123 // Aliases: homeDir, homeFolder 1124 func home() string 1125 ``` 1126 1127 ```go 1128 // Determines if the file is a directory. 1129 // Aliases: isDirectory, isFolder 1130 func isDir(filename interface{}) bool, error 1131 ``` 1132 1133 ```go 1134 // Determines if the file is executable by the current user. 1135 func isExecutable(filename interface{}) bool, error 1136 ``` 1137 1138 ```go 1139 // Determines if the file is a file (i.e. not a directory). 1140 func isFile(filename interface{}) bool, error 1141 ``` 1142 1143 ```go 1144 // Determines if the file is readable by the current user. 1145 func isReadable(filename interface{}) bool, error 1146 ``` 1147 1148 ```go 1149 // Determines if the file is writeable by the current user. 1150 func isWriteable(filename interface{}) bool, error 1151 ``` 1152 1153 ```go 1154 // Returns the last modification time of the file. 1155 // Aliases: lastModification, lastModificationTime 1156 func lastMod(filename interface{}) time.Time, error 1157 ``` 1158 1159 ```go 1160 // Returns the location of the specified executable (returns empty string if not found). 1161 // Aliases: whereIs, look, which, type 1162 func lookPath(arg1 interface{}) string 1163 ``` 1164 1165 ```go 1166 // Returns the file mode. 1167 // Aliases: fileMode 1168 func mode(filename interface{}) os.FileMode, error 1169 ``` 1170 1171 ```go 1172 // Returns the current working directory. 1173 // Aliases: currentDir 1174 func pwd() string 1175 ``` 1176 1177 ```go 1178 // Save object to file. 1179 // Aliases: write, writeTo 1180 func save(filename string, object interface{}) string, error 1181 ``` 1182 1183 ```go 1184 // Returns the file size. 1185 // Aliases: fileSize 1186 func size(filename interface{}) int64, error 1187 ``` 1188 1189 ```go 1190 // Returns the file Stat information (os.Stat object). 1191 // Aliases: fileStat 1192 func stat(arg1 string) os.FileInfo, error 1193 ``` 1194 1195 ```go 1196 // Returns the current user information (user.User object). 1197 // Aliases: currentUser 1198 func user() *user.User, error 1199 ``` 1200 1201 ```go 1202 // Returns the current user name. 1203 func username() string 1204 ``` 1205 ### Other utilities 1206 1207 ```go 1208 // Returns the concatenation of supplied arguments centered within width. 1209 // Aliases: centered 1210 func center(width interface{}, args ...interface{}) string, error 1211 ``` 1212 1213 ```go 1214 // Colors the rendered string. 1215 // 1216 // The first arguments are interpretated as color attributes until the first non color attribute. Attributes are case insensitive. 1217 // 1218 // Valid attributes are: 1219 // Reset, Bold, Faint, Italic, Underline, BlinkSlow, BlinkRapid, ReverseVideo, Concealed, CrossedOut 1220 // 1221 // Valid color are: 1222 // Black, Red, Green, Yellow, Blue, Magenta, Cyan, White 1223 // 1224 // Color can be prefixed by: 1225 // Fg: Meaning foreground (Fg is assumed if not specified) 1226 // FgHi: Meaning high intensity forground 1227 // Bg: Meaning background" 1228 // BgHi: Meaning high intensity background 1229 // Aliases: colored, enhanced 1230 func color(args ...interface{}) string, error 1231 ``` 1232 1233 ```go 1234 // Returns the concatenation (without separator) of the string representation of objects. 1235 func concat(args ...interface{}) string 1236 ``` 1237 1238 ```go 1239 // Return a list of strings by applying the format to each element of the supplied list. 1240 // 1241 // You can also use autoWrap as Razor expression if you don't want to specify the format. 1242 // The format is then automatically induced by the context around the declaration). 1243 // Valid aliases for autoWrap are: aWrap, awrap. 1244 // 1245 // Ex: 1246 // Hello @<autoWrap(to(10)) World! 1247 // Aliases: autoWrap, aWrap, awrap 1248 func formatList(format string, list ...interface{}) IGenericList 1249 ``` 1250 1251 ```go 1252 // Returns a valid go identifier from the supplied string (replacing any non compliant character by replacement, default _ ). 1253 // Aliases: identifier 1254 func id(identifier string, replaceChar ...interface{}) string 1255 ``` 1256 1257 ```go 1258 // If testValue is empty, returns falseValue, otherwise returns trueValue. 1259 // WARNING: All arguments are evaluated and must by valid. 1260 // Aliases: ternary 1261 func iif(testValue interface{}, valueTrue interface{}, valueFalse interface{}) interface{} 1262 ``` 1263 1264 ```go 1265 // Indents every line in a given string to the specified indent width. This is useful when aligning multi-line strings. 1266 func indent(nbSpace int, args ...interface{}) string 1267 ``` 1268 1269 ```go 1270 // Merge the supplied objects into a newline separated string. 1271 func joinLines(format ...interface{}) string 1272 ``` 1273 1274 ```go 1275 // Returns a random string. Valid types are be word, words, sentence, para, paragraph, host, email, url. 1276 // Aliases: loremIpsum 1277 func lorem(loremType interface{}, params ...int) string, error 1278 ``` 1279 1280 ```go 1281 // Return a single list containing all elements from the lists supplied. 1282 func mergeList(lists ...IGenericList) IGenericList 1283 ``` 1284 1285 ```go 1286 // Aliases: nindent 1287 func nIndent(nbSpace int, args ...interface{}) string 1288 ``` 1289 1290 ```go 1291 // Returns an array with the item repeated n times. 1292 func repeat(n int, element interface{}) IGenericList, error 1293 ``` 1294 1295 ```go 1296 // Indents the elements using the provided spacer. 1297 // 1298 // You can also use autoIndent as Razor expression if you don't want to specify the spacer. 1299 // Spacer will then be auto determined by the spaces that precede the expression. 1300 // Valid aliases for autoIndent are: aIndent, aindent. 1301 // Aliases: sindent, spaceIndent, autoIndent, aindent, aIndent 1302 func sIndent(spacer string, args ...interface{}) string 1303 ``` 1304 1305 ```go 1306 // Returns a list of strings from the supplied object with newline as the separator. 1307 func splitLines(content interface{}) []interface{} 1308 ``` 1309 1310 ```go 1311 // Wraps the rendered arguments within width. 1312 // Aliases: wrapped 1313 func wrap(width interface{}, args ...interface{}) string, error 1314 ``` 1315 ### Runtime 1316 1317 ```go 1318 // Defines an alias (go template function) using the function (exec, run, include, template). Executed in the context of the caller. 1319 func alias(name string, function string, source interface{}, args ...interface{}) string, error 1320 ``` 1321 1322 ```go 1323 // Returns the list of all functions that are simply an alias of another function. 1324 func aliases() []string 1325 ``` 1326 1327 ```go 1328 // Returns the list of all available functions. 1329 func allFunctions() []string 1330 ``` 1331 1332 ```go 1333 // Raises a formated error if the test condition is false. 1334 // Aliases: assertion 1335 func assert(test interface{}, message ...interface{}) string, error 1336 ``` 1337 1338 ```go 1339 // Issues a formated warning if the test condition is false. 1340 // Aliases: assertw 1341 func assertWarning(test interface{}, message ...interface{}) string 1342 ``` 1343 1344 ```go 1345 // Returns all functions group by categories. 1346 // 1347 // The returned value has the following properties: 1348 // Name string 1349 // Functions []string 1350 func categories() []template.FuncCategory 1351 ``` 1352 1353 ```go 1354 // Returns the current folder (like pwd, but returns the folder of the currently running folder). 1355 func current() string 1356 ``` 1357 1358 ```go 1359 // Returns the result of the function by expanding its last argument that must be an array into values. It's like calling function(arg1, arg2, otherArgs...). 1360 func ellipsis(function string, args ...interface{}) interface{}, error 1361 ``` 1362 1363 ```go 1364 // Returns the result of the shell command as structured data (as string if no other conversion is possible). 1365 // Aliases: execute 1366 func exec(command interface{}, args ...interface{}) interface{}, error 1367 ``` 1368 1369 ```go 1370 // Exits the current program execution. 1371 func exit(exitValue int) int 1372 ``` 1373 1374 ```go 1375 // Defines a function with the current context using the function (exec, run, include, template). Executed in the context of the caller. 1376 func func(name string, function string, source interface{}, config interface{}) string, error 1377 ``` 1378 1379 ```go 1380 // Returns the information relative to a specific function. 1381 // 1382 // The returned value has the following properties: 1383 // Name string 1384 // Description string 1385 // Signature string 1386 // Group string 1387 // Aliases []string 1388 // Arguments string 1389 // Result string 1390 func function(name string) template.FuncInfo 1391 ``` 1392 1393 ```go 1394 // Returns the list of all available functions (excluding aliases). 1395 func functions() []string 1396 ``` 1397 1398 ```go 1399 // List all attributes accessible from the supplied object. 1400 // Aliases: attr, attributes 1401 func getAttributes(arg1 interface{}) string 1402 ``` 1403 1404 ```go 1405 // List all methods signatures accessible from the supplied object. 1406 // Aliases: methods 1407 func getMethods(arg1 interface{}) string 1408 ``` 1409 1410 ```go 1411 // List all attributes and methods signatures accessible from the supplied object. 1412 // Aliases: sign, signature 1413 func getSignature(arg1 interface{}) string 1414 ``` 1415 1416 ```go 1417 // Returns the result of the named template rendering (like template but it is possible to capture the output). 1418 func include(source interface{}, context ...interface{}) interface{}, error 1419 ``` 1420 1421 ```go 1422 // Defines an alias (go template function) using the function (exec, run, include, template). Executed in the context of the function it maps to. 1423 func localAlias(name string, function string, source interface{}, args ...interface{}) string, error 1424 ``` 1425 1426 ```go 1427 // Raise a formated error. 1428 // Aliases: raiseError 1429 func raise(args ...interface{}) string, error 1430 ``` 1431 1432 ```go 1433 // Returns the result of the shell command as string. 1434 func run(command interface{}, args ...interface{}) interface{}, error 1435 ``` 1436 1437 ```go 1438 // Applies the supplied regex substitute specified on the command line on the supplied string (see --substitute). 1439 func substitute(content string) string 1440 ``` 1441 1442 ```go 1443 // Returns the list of available templates names. 1444 func templateNames() []string 1445 ``` 1446 1447 ```go 1448 // Returns the list of available templates. 1449 func templates() []*template.Template 1450 ``` 1451 ### Sprig Cryptographic & Security, http://masterminds.github.io/sprig/crypto.html 1452 1453 ```go 1454 // Computes Adler-32 checksum. 1455 func adler32sum(input string) string 1456 ``` 1457 1458 ```go 1459 func buildCustomCert(arg1 string, arg2 string) sprig.certificate, error 1460 ``` 1461 1462 ```go 1463 func derivePassword(arg1 uint32, arg2 string, arg3 string, arg4 string, arg5 string) string 1464 ``` 1465 1466 ```go 1467 func genCA(arg1 string, arg2 int) sprig.certificate, error 1468 ``` 1469 1470 ```go 1471 // Generates a new private key encoded into a PEM block. Type should be: ecdsa, dsa or rsa 1472 func genPrivateKey(type string) string 1473 ``` 1474 1475 ```go 1476 func genSelfSignedCert(arg1 string, arg2 []interface{}, arg3 []interface{}, arg4 int) sprig.certificate, error 1477 ``` 1478 1479 ```go 1480 func genSignedCert(arg1 string, arg2 []interface{}, arg3 []interface{}, arg4 int, arg5 sprig.certificate) sprig.certificate, error 1481 ``` 1482 1483 ```go 1484 // Computes SHA1 digest. 1485 func sha1sum(input string) string 1486 ``` 1487 1488 ```go 1489 // Computes SHA256 digest. 1490 func sha256sum(input string) string 1491 ``` 1492 ### Sprig Date, http://masterminds.github.io/sprig/date.html 1493 1494 ```go 1495 // The ago function returns duration from time.Now in seconds resolution. 1496 func ago(date interface{}) string 1497 ``` 1498 1499 ```go 1500 // The date function formats a dat (https://golang.org/pkg/time/#Time.Format). 1501 func date(fmt string, date interface{}) string 1502 ``` 1503 1504 ```go 1505 // Same as date, but with a timezone. 1506 // Aliases: date_in_zone 1507 func dateInZone(fmt string, date interface{}, zone string) string 1508 ``` 1509 1510 ```go 1511 // The dateModify takes a modification and a date and returns the timestamp. 1512 // Aliases: date_modify 1513 func dateModify(fmt string, date time.Time) time.Time 1514 ``` 1515 1516 ```go 1517 // The htmlDate function formates a date for inserting into an HTML date picker input field. 1518 func htmlDate(date interface{}) string 1519 ``` 1520 1521 ```go 1522 // Same as htmlDate, but with a timezone. 1523 func htmlDateInZone(date interface{}, zone string) string 1524 ``` 1525 1526 ```go 1527 // The current date/time. Use this in conjunction with other date functions. 1528 func now() time.Time 1529 ``` 1530 1531 ```go 1532 // Converts a string to a date. The first argument is the date layout and the second the date string. If the string can’t be convert it returns the zero value. 1533 func toDate(fmt string, str string) time.Time 1534 ``` 1535 ### Sprig Default, http://masterminds.github.io/sprig/defaults.html 1536 1537 ```go 1538 func coalesce(args ...interface{}) interface{} 1539 ``` 1540 1541 ```go 1542 func compact(arg1 interface{}) []interface{} 1543 ``` 1544 1545 ```go 1546 func default(arg1 interface{}, args ...interface{}) interface{} 1547 ``` 1548 1549 ```go 1550 func empty(arg1 interface{}) bool 1551 ``` 1552 1553 ```go 1554 // Aliases: ternary 1555 func ternarySprig(arg1 interface{}, arg2 interface{}, arg3 bool) interface{} 1556 ``` 1557 1558 ```go 1559 // Aliases: toJson 1560 func toJsonSprig(arg1 interface{}) string 1561 ``` 1562 1563 ```go 1564 // Aliases: toPrettyJson 1565 func toPrettyJsonSprig(arg1 interface{}) string 1566 ``` 1567 ### Sprig Dictionnary, http://masterminds.github.io/sprig/dicst.html 1568 1569 ```go 1570 // Aliases: dict 1571 func dictSprig(args ...interface{}) map[string]interface{} 1572 ``` 1573 1574 ```go 1575 // Aliases: hasKey 1576 func hasKeySprig(arg1 map[string]interface{}, arg2 string) bool 1577 ``` 1578 1579 ```go 1580 // Aliases: keys 1581 func keysSprig(args ...map[string]interface{}) []string 1582 ``` 1583 1584 ```go 1585 // Aliases: list, tuple, tupleSprig 1586 func listSprig(args ...interface{}) []interface{} 1587 ``` 1588 1589 ```go 1590 // Merge two or more dictionaries into one, giving precedence from **right to left**, effectively overwriting values in the dest dictionary 1591 func mergeOverwrite(arg1 map[string]interface{}, args ...map[string]interface{}) interface{} 1592 ``` 1593 1594 ```go 1595 // Aliases: merge 1596 func mergeSprig(arg1 map[string]interface{}, args ...map[string]interface{}) interface{} 1597 ``` 1598 1599 ```go 1600 // Aliases: omit 1601 func omitSprig(arg1 map[string]interface{}, args ...string) map[string]interface{} 1602 ``` 1603 1604 ```go 1605 // Aliases: pick 1606 func pickSprig(arg1 map[string]interface{}, args ...string) map[string]interface{} 1607 ``` 1608 1609 ```go 1610 // Aliases: pluck 1611 func pluckSprig(arg1 string, args ...map[string]interface{}) []interface{} 1612 ``` 1613 1614 ```go 1615 // Aliases: set 1616 func setSprig(arg1 map[string]interface{}, arg2 string, arg3 interface{}) map[string]interface{} 1617 ``` 1618 1619 ```go 1620 // Aliases: unset 1621 func unsetSprig(arg1 map[string]interface{}, arg2 string) map[string]interface{} 1622 ``` 1623 1624 ```go 1625 // Aliases: values 1626 func valuesSprig(arg1 map[string]interface{}) []interface{} 1627 ``` 1628 ### Sprig Encoding, http://masterminds.github.io/sprig/encoding.html 1629 1630 ```go 1631 func b32dec(arg1 string) string 1632 ``` 1633 1634 ```go 1635 func b32enc(arg1 string) string 1636 ``` 1637 1638 ```go 1639 func b64dec(arg1 string) string 1640 ``` 1641 1642 ```go 1643 func b64enc(arg1 string) string 1644 ``` 1645 ### Sprig File Path, http://masterminds.github.io/sprig/paths.html 1646 1647 ```go 1648 func base(arg1 string) string 1649 ``` 1650 1651 ```go 1652 func clean(arg1 string) string 1653 ``` 1654 1655 ```go 1656 func dir(arg1 string) string 1657 ``` 1658 1659 ```go 1660 func ext(arg1 string) string 1661 ``` 1662 1663 ```go 1664 func isAbs(arg1 string) bool 1665 ``` 1666 ### Sprig Flow Control, http://masterminds.github.io/sprig/flow_control.html 1667 1668 ```go 1669 // Unconditionally returns an empty string and an error with the specified text. This is useful in scenarios where other conditionals have determined that template rendering should fail. 1670 func fail(arg1 string) string, error 1671 ``` 1672 ### Sprig General, http://masterminds.github.io/sprig/ 1673 1674 ```go 1675 // Simple hello by Sprig 1676 func hello() string 1677 ``` 1678 1679 ```go 1680 // Aliases: uuid, guid, GUID 1681 func uuidv4() string 1682 ``` 1683 ### Sprig List, http://masterminds.github.io/sprig/lists.html 1684 1685 ```go 1686 // Aliases: append, push, pushSprig 1687 func appendSprig(arg1 interface{}, arg2 interface{}) []interface{} 1688 ``` 1689 1690 ```go 1691 func first(arg1 interface{}) interface{} 1692 ``` 1693 1694 ```go 1695 // Aliases: has 1696 func hasSprig(arg1 interface{}, arg2 interface{}) bool 1697 ``` 1698 1699 ```go 1700 // Aliases: initial 1701 func initialSprig(arg1 interface{}) []interface{} 1702 ``` 1703 1704 ```go 1705 func last(arg1 interface{}) interface{} 1706 ``` 1707 1708 ```go 1709 // Aliases: prepend 1710 func prependSprig(arg1 interface{}, arg2 interface{}) []interface{} 1711 ``` 1712 1713 ```go 1714 // Aliases: rest 1715 func restSprig(arg1 interface{}) []interface{} 1716 ``` 1717 1718 ```go 1719 // Aliases: reverse 1720 func reverseSprig(arg1 interface{}) []interface{} 1721 ``` 1722 1723 ```go 1724 // Aliases: slice 1725 func sliceSprig(arg1 interface{}, args ...interface{}) interface{} 1726 ``` 1727 1728 ```go 1729 // Aliases: uniq 1730 func uniqSprig(arg1 interface{}) []interface{} 1731 ``` 1732 1733 ```go 1734 // Aliases: without 1735 func withoutSprig(arg1 interface{}, args ...interface{}) []interface{} 1736 ``` 1737 ### Sprig Mathematics, http://masterminds.github.io/sprig/math.html 1738 1739 ```go 1740 func add1(arg1 interface{}) int64 1741 ``` 1742 1743 ```go 1744 // Aliases: add 1745 func addSprig(args ...interface{}) int64 1746 ``` 1747 1748 ```go 1749 // Aliases: ceil 1750 func ceilSprig(arg1 interface{}) float64 1751 ``` 1752 1753 ```go 1754 // Aliases: div 1755 func divSprig(arg1 interface{}, arg2 interface{}) int64 1756 ``` 1757 1758 ```go 1759 // Aliases: floor 1760 func floorSprig(arg1 interface{}) float64 1761 ``` 1762 1763 ```go 1764 // Aliases: max, biggest, biggestSprig 1765 func maxSprig(arg1 interface{}, args ...interface{}) int64 1766 ``` 1767 1768 ```go 1769 // Aliases: min 1770 func minSprig(arg1 interface{}, args ...interface{}) int64 1771 ``` 1772 1773 ```go 1774 // Aliases: mod 1775 func modSprig(arg1 interface{}, arg2 interface{}) int64 1776 ``` 1777 1778 ```go 1779 // Aliases: mul 1780 func mulSprig(arg1 interface{}, args ...interface{}) int64 1781 ``` 1782 1783 ```go 1784 func round(arg1 interface{}, arg2 int, args ...float64) float64 1785 ``` 1786 1787 ```go 1788 // Aliases: sub 1789 func subSprig(arg1 interface{}, arg2 interface{}) int64 1790 ``` 1791 1792 ```go 1793 func untilStep(arg1 int, arg2 int, arg3 int) []int 1794 ``` 1795 ### Sprig OS, http://masterminds.github.io/sprig/defaults.html 1796 1797 ```go 1798 func env(arg1 string) string 1799 ``` 1800 1801 ```go 1802 func expandenv(arg1 string) string 1803 ``` 1804 ### Sprig Reflection, http://masterminds.github.io/sprig/reflection.html 1805 1806 ```go 1807 // Aliases: kindis 1808 func kindIs(arg1 string, arg2 interface{}) bool 1809 ``` 1810 1811 ```go 1812 // Aliases: kindof 1813 func kindOf(arg1 interface{}) string 1814 ``` 1815 1816 ```go 1817 // Aliases: typeis 1818 func typeIs(arg1 string, arg2 interface{}) bool 1819 ``` 1820 1821 ```go 1822 // Aliases: typeisLike 1823 func typeIsLike(arg1 string, arg2 interface{}) bool 1824 ``` 1825 1826 ```go 1827 // Aliases: typeof 1828 func typeOf(arg1 interface{}) string 1829 ``` 1830 ### Sprig Regex, http://masterminds.github.io/sprig/strings.html 1831 1832 ```go 1833 // Returns the first (left most) match of the regular expression in the input string. 1834 func regexFind(regex string, str string) string 1835 ``` 1836 1837 ```go 1838 // Returns a slice of all matches of the regular expression in the input string. 1839 func regexFindAll(regex string, str string, n int) []string 1840 ``` 1841 1842 ```go 1843 // Returns true if the input string matches the regular expression. 1844 func regexMatch(regex string, str string) bool 1845 ``` 1846 1847 ```go 1848 // Returns a copy of the input string, replacing matches of the Regexp with the replacement string replacement. Inside string replacement, $ signs are interpreted as in Expand, so for instance $1 represents the text of the first submatch. 1849 func regexReplaceAll(regex string, str string, repl string) string 1850 ``` 1851 1852 ```go 1853 // Returns a copy of the input string, replacing matches of the Regexp with the replacement string replacement The replacement string is substituted directly, without using Expand. 1854 func regexReplaceAllLiteral(regex string, str string, repl string) string 1855 ``` 1856 1857 ```go 1858 // Slices the input string into substrings separated by the expression and returns a slice of the substrings between those expression matches. The last parameter n determines the number of substrings to return, where -1 means return all matches. 1859 func regexSplit(regex string, str string, n int) []string 1860 ``` 1861 ### Sprig String Slice, http://masterminds.github.io/sprig/string_slice.html 1862 1863 ```go 1864 func join(arg1 string, arg2 interface{}) string 1865 ``` 1866 1867 ```go 1868 func sortAlpha(arg1 interface{}) []string 1869 ``` 1870 1871 ```go 1872 func split(arg1 string, arg2 string) map[string]string 1873 ``` 1874 1875 ```go 1876 func splitList(arg1 string, arg2 string) []string 1877 ``` 1878 1879 ```go 1880 func splitn(arg1 string, arg2 int, arg3 string) map[string]string 1881 ``` 1882 1883 ```go 1884 func toStrings(arg1 interface{}) []string 1885 ``` 1886 ### Sprig Strings, http://masterminds.github.io/sprig/strings.html 1887 1888 ```go 1889 // Truncates a string with ellipses (...). 1890 func abbrev(width int, str string) string 1891 ``` 1892 1893 ```go 1894 // Abbreviates both sides with ellipses (...). 1895 func abbrevboth(left int, right int, str string) string 1896 ``` 1897 1898 ```go 1899 // Converts string from snake_case to CamelCase. 1900 func camelcase(str string) string 1901 ``` 1902 1903 ```go 1904 // Concatenates multiple strings together into one, separating them with spaces. 1905 func cat(args ...interface{}) string 1906 ``` 1907 1908 ```go 1909 // Tests to see if one string is contained inside of another. 1910 // Aliases: contains 1911 func containsSprig(substr string, str string) bool 1912 ``` 1913 1914 ```go 1915 // Tests whether a string has a given prefix. 1916 func hasPrefix(prefix string, str string) bool 1917 ``` 1918 1919 ```go 1920 // Tests whether a string has a given suffix. 1921 func hasSuffix(suffix string, str string) bool 1922 ``` 1923 1924 ```go 1925 // Indents every line in a given string to the specified indent width. This is useful when aligning multi-line strings. 1926 // Aliases: indent 1927 func indentSprig(spaces int, str string) string 1928 ``` 1929 1930 ```go 1931 // Given multiple words, takes the first letter of each word and combine. 1932 func initials(str string) string 1933 ``` 1934 1935 ```go 1936 // Convert string from camelCase to kebab-case. 1937 func kebabcase(str string) string 1938 ``` 1939 1940 ```go 1941 // Converts the entire string to lowercase. 1942 func lower(str string) string 1943 ``` 1944 1945 ```go 1946 // Same as the indent function, but prepends a new line to the beginning of the string. 1947 // Aliases: nindent 1948 func nindentSprig(spaces int, str string) string 1949 ``` 1950 1951 ```go 1952 // Removes all whitespace from a string. 1953 func nospace(str string) string 1954 ``` 1955 1956 ```go 1957 // Pluralizes a string. 1958 func plural(one string, many string, count int) string 1959 ``` 1960 1961 ```go 1962 // Wraps each argument with double quotes. 1963 func quote(str ...interface{}) string 1964 ``` 1965 1966 ```go 1967 // Generates random string with letters. 1968 func randAlpha(count int) string 1969 ``` 1970 1971 ```go 1972 // Generates random string with letters and digits. 1973 func randAlphaNum(count int) string 1974 ``` 1975 1976 ```go 1977 // Generates random string with ASCII printable characters. 1978 func randAscii(count int) string 1979 ``` 1980 1981 ```go 1982 // Generates random string with digits. 1983 func randNumeric(count int) string 1984 ``` 1985 1986 ```go 1987 // Repeats a string multiple times. 1988 // Aliases: repeat 1989 func repeatSprig(count int, str string) string 1990 ``` 1991 1992 ```go 1993 // Performs simple string replacement. 1994 func replace(old string, new string, src string) string 1995 ``` 1996 1997 ```go 1998 // Shuffle a string. 1999 func shuffle(str string) string 2000 ``` 2001 2002 ```go 2003 // Converts string from camelCase to snake_case. 2004 func snakecase(str string) string 2005 ``` 2006 2007 ```go 2008 // Wraps each argument with single quotes. 2009 func squote(args ...interface{}) string 2010 ``` 2011 2012 ```go 2013 // Get a substring from a string. 2014 func substr(start int, length int, str string) string 2015 ``` 2016 2017 ```go 2018 // Swaps the uppercase to lowercase and lowercase to uppercase. 2019 func swapcase(str string) string 2020 ``` 2021 2022 ```go 2023 // Converts to title case. 2024 func title(str string) string 2025 ``` 2026 2027 ```go 2028 // Converts any value to string. 2029 func toString(value interface{}) string 2030 ``` 2031 2032 ```go 2033 // Removes space from either side of a string. 2034 func trim(str string) string 2035 ``` 2036 2037 ```go 2038 // Removes given characters from the front or back of a string. 2039 // Aliases: trimall 2040 func trimAll(chars string, str string) string 2041 ``` 2042 2043 ```go 2044 // Trims just the prefix from a string if present. 2045 func trimPrefix(prefix string, str string) string 2046 ``` 2047 2048 ```go 2049 // Trims just the suffix from a string if present. 2050 func trimSuffix(suffix string, str string) string 2051 ``` 2052 2053 ```go 2054 // Truncates a string (and add no suffix). 2055 // Aliases: trunc 2056 func truncSprig(length int, str string) string 2057 ``` 2058 2059 ```go 2060 // Removes title casing. 2061 func untitle(str string) string 2062 ``` 2063 2064 ```go 2065 // Converts the entire string to uppercase. 2066 func upper(str string) string 2067 ``` 2068 2069 ```go 2070 // Wraps text at a given column count. 2071 // Aliases: wrap 2072 func wrapSprig(length int, str string) string 2073 ``` 2074 2075 ```go 2076 // Works as wrap, but lets you specify the string to wrap with (wrap uses \n). 2077 func wrapWith(length int, spe string, str string) string 2078 ``` 2079 ### Sprig Type Conversion, http://masterminds.github.io/sprig/conversion.html 2080 2081 ```go 2082 func atoi(arg1 string) int 2083 ``` 2084 2085 ```go 2086 func float64(arg1 interface{}) float64 2087 ``` 2088 2089 ```go 2090 func int64(arg1 interface{}) int64 2091 ``` 2092 2093 ```go 2094 // Aliases: int 2095 func intSprig(arg1 interface{}) int 2096 ``` 2097 ### Sprig Version comparison, http://masterminds.github.io/sprig/semver.html 2098 2099 ```go 2100 // Parses a string into a Semantic Version. 2101 func semver(version string) *semver.Version, error 2102 ``` 2103 2104 ```go 2105 // A more robust comparison function is provided as semverCompare. This version supports version ranges. 2106 func semverCompare(constraints string, version string) bool, error 2107 ``` 2108