Merge commit '9b0050e9aabe4be65c78ccf292a348f309d50ccd' as 'docs'

```
git subtree add --prefix=docs/ https://github.com/gohugoio/hugoDocs.git master --squash
```

Closes #11925
This commit is contained in:
Bjørn Erik Pedersen
2024-01-27 10:48:33 +01:00
1158 changed files with 64103 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
---
title: math.Abs
description: Returns the absolute value of the given number.
categories: []
keywords: []
action:
aliases: []
related: []
returnType: float64
signatures: [math.Abs VALUE]
---
{{< new-in 0.112.0 >}}
```go-html-template
{{ math.Abs -2.1 }} → 2.1
```

View File

@@ -0,0 +1,24 @@
---
title: math.Add
description: Adds two or more numbers.
categories: []
keywords: []
action:
aliases: [add]
related:
- functions/math/Div
- functions/math/Mul
- functions/math/Product
- functions/math/Sub
- functions/math/Sum
returnType: any
signatures: [math.Add VALUE VALUE...]
---
If one of the numbers is a [`float`], the result is a `float`.
```go-html-template
{{ add 12 3 2 }} → 17
```
[`float`]: /getting-started/glossary/#float

View File

@@ -0,0 +1,17 @@
---
title: math.Ceil
description: Returns the least integer value greater than or equal to the given number.
categories: []
keywords: []
action:
aliases: []
related:
- functions/math/Floor
- functions/math/Round
returnType: float64
signatures: [math.Ceil VALUE]
---
```go-html-template
{{ math.Ceil 2.1 }} → 3
```

View File

@@ -0,0 +1,35 @@
---
title: math.Counter
description: Increments and returns a global counter.
categories: []
keywords: []
action:
aliases: []
related: []
returnType: uint64
signatures: [math.Counter]
---
The counter is global for both monolingual and multilingual sites, and its initial value for each build is&nbsp;1.
```go-html-template
{{ warnf "single.html called %d times" math.Counter }}
```
```sh
WARN single.html called 1 times
WARN single.html called 2 times
WARN single.html called 3 times
```
Use this function to:
- Create unique warnings as shown above; the [`warnf`] function suppresses duplicate messages
- Create unique target paths for the `resources.FromString` function where the target path is also the cache key
[`warnf`]: /functions/fmt/warnf
[`resources.FromString`]: /functions/resources/fromstring
{{% note %}}
Due to concurrency, the value returned in a given template for a given page will vary from one build to the next. You cannot use this function to assign a static id to each page.
{{% /note %}}

View File

@@ -0,0 +1,24 @@
---
title: math.Div
description: Divides the first number by one or more numbers.
categories: []
keywords: []
action:
aliases: [div]
related:
- functions/math/Add
- functions/math/Mul
- functions/math/Product
- functions/math/Sub
- functions/math/Sum
returnType: any
signatures: [math.Div VALUE VALUE...]
---
If one of the numbers is a [`float`], the result is a `float`.
```go-html-template
{{ div 12 3 2 }} → 2
```
[`float`]: /getting-started/glossary/#float

View File

@@ -0,0 +1,17 @@
---
title: math.Floor
description: Returns the greatest integer value less than or equal to the given number.
categories: []
keywords: []
action:
aliases: []
related:
- functions/math/Ceil
- functions/math/Round
returnType: float64
signatures: [math.Floor VALUE]
---
```go-html-template
{{ math.Floor 1.9 }} → 1
```

View File

@@ -0,0 +1,15 @@
---
title: math.Log
description: Returns the natural logarithm of the given number.
categories: []
keywords: []
action:
aliases: []
related: []
returnType: float64
signatures: [math.Log VALUE]
---
```go-html-template
{{ math.Log 42 }} → 3.737
```

View File

@@ -0,0 +1,16 @@
---
title: math.Max
description: Returns the greater of all numbers. Accepts scalars, slices, or both.
categories: []
keywords: []
action:
aliases: []
related:
- functions/math/Min
returnType: float64
signatures: [math.Max VALUE...]
---
```go-html-template
{{ math.Max 1 (slice 2 3) 4 }} → 4
```

View File

@@ -0,0 +1,16 @@
---
title: math.Min
description: Returns the smaller of all numbers. Accepts scalars, slices, or both.
categories: []
keywords: []
action:
aliases: []
related:
- functions/math/Max
returnType: float64
signatures: [math.Min VALUE...]
---
```go-html-template
{{ math.Min 1 (slice 2 3) 4 }} → 1
```

View File

@@ -0,0 +1,16 @@
---
title: math.Mod
description: Returns the modulus of two integers.
categories: []
keywords: []
action:
aliases: [mod]
related:
- functions/math/ModBool
returnType: int64
signatures: [math.Mod VALUE1 VALUE2]
---
```go-html-template
{{ mod 15 3 }} → 0
```

View File

@@ -0,0 +1,16 @@
---
title: math.ModBool
description: Reports whether the modulus of two integers equals 0.
categories: []
keywords: []
action:
aliases: [modBool]
related:
- functions/math/Mod
returnType: bool
signatures: [math.ModBool VALUE1 VALUE2]
---
```go-html-template
{{ modBool 15 3 }} → true
```

View File

@@ -0,0 +1,24 @@
---
title: math.Mul
description: Multiplies two or more numbers.
categories: []
keywords: []
action:
aliases: [mul]
related:
- functions/math/Add
- functions/math/Div
- functions/math/Product
- functions/math/Sub
- functions/math/Sum
returnType: any
signatures: [math.Mul VALUE VALUE...]
---
If one of the numbers is a [`float`], the result is a `float`.
```go-html-template
{{ mul 12 3 2 }} → 72
```
[`float`]: /getting-started/glossary/#float

View File

@@ -0,0 +1,16 @@
---
title: math.Pow
description: Returns the first number raised to the power of the second number.
categories: []
keywords: []
action:
aliases: [pow]
related:
- functions/math/Sqrt
returnType: float64
signatures: [math.Pow VALUE1 VALUE2]
---
```go-html-template
{{ math.Pow 2 3 }} → 8
```

View File

@@ -0,0 +1,22 @@
---
title: math.Product
description: Returns the product of all numbers. Accepts scalars, slices, or both.
categories: []
keywords: []
action:
aliases: []
related:
- functions/math/Add
- functions/math/Div
- functions/math/Mul
- functions/math/Sub
- functions/math/Sum
returnType: float64
signatures: [math.Product VALUE...]
---
{{< new-in 0.114.0 >}}
```go-html-template
{{ math.Product 1 (slice 2 3) 4 }} → 24
```

View File

@@ -0,0 +1,46 @@
---
title: math.Rand
description: Returns a pseudo-random number in the half-open interval [0.0, 1.0).
categories: []
keywords: []
action:
aliases: []
related: []
returnType: float64
signatures: [math.Rand]
---
{{< new-in 0.121.2 >}}
The `math.Rand` function returns a pseudo-random number in the [half-open interval] [0.0, 1.0).
```go-html-template
{{ math.Rand }} → 0.6312770459590062
```
To generate a random integer in the [closed interval] [0, 5]:
```go-html-template
{{ math.Rand | mul 6 | math.Floor }}
```
To generate a random integer in the closed interval [1, 6]:
```go-html-template
{{ math.Rand | mul 6 | math.Ceil }}
```
To generate a random float, with one digit after the decimal point, in the closed interval [0, 4.9]:
```go-html-template
{{ div (math.Rand | mul 50 | math.Floor) 10 }}
```
To generate a random float, with one digit after the decimal point, in the closed interval [0.1, 5.0]:
```go-html-template
{{ div (math.Rand | mul 50 | math.Ceil) 10 }}
```
[closed interval]: /getting-started/glossary/#interval
[half-open interval]: /getting-started/glossary/#interval

View File

@@ -0,0 +1,17 @@
---
title: math.Round
description: Returns the nearest integer, rounding half away from zero.
categories: []
keywords: []
action:
aliases: []
related:
- functions/math/Ceil
- functions/math/Floor
returnType: float64
signatures: [math.Round VALUE]
---
```go-html-template
{{ math.Round 1.5 }} → 2
```

View File

@@ -0,0 +1,16 @@
---
title: math.Sqrt
description: Returns the square root of the given number.
categories: []
keywords: []
action:
aliases: []
related:
- functions/math/Pow
returnType: float64
signatures: [math.Sqrt VALUE]
---
```go-html-template
{{ math.Sqrt 81 }} → 9
```

View File

@@ -0,0 +1,24 @@
---
title: math.Sub
description: Subtracts one or more numbers from the first number.
categories: []
keywords: []
action:
aliases: [sub]
related:
- functions/math/Add
- functions/math/Div
- functions/math/Mul
- functions/math/Product
- functions/math/Sum
returnType: any
signatures: [math.Sub VALUE VALUE...]
---
If one of the numbers is a [`float`], the result is a `float`.
```go-html-template
{{ sub 12 3 2 }} → 7
```
[`float`]: /getting-started/glossary/#float

View File

@@ -0,0 +1,21 @@
---
title: math.Sum
description: Returns the sum of all numbers. Accepts scalars, slices, or both.
categories: []
action:
aliases: []
related:
- functions/math/Add
- functions/math/Div
- functions/math/Mul
- functions/math/Product
- functions/math/Sub
returnType: float64
signatures: [math.Sum VALUE...]
---
{{< new-in 0.114.0 >}}
```go-html-template
{{ math.Sum 1 (slice 2 3) 4 }} → 10
```

View File

@@ -0,0 +1,11 @@
---
title: Math functions
linkTitle: math
description: Template functions to perform mathematical operations.
categories: []
menu:
docs:
parent: functions
---
Use these functions to perform mathematical operations.