Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'

This commit is contained in:
Bjørn Erik Pedersen
2023-12-04 15:24:01 +01:00
810 changed files with 24147 additions and 7766 deletions

View File

@@ -1,26 +1,21 @@
---
title: fmt.Errorf
linkTitle: errorf
description: Log an ERROR from a template.
categories: [functions]
categories: []
keywords: []
menu:
docs:
parent: functions
function:
action:
aliases: [errorf]
related:
- functions/fmt/Erroridf
- functions/fmt/Warnf
returnType: string
signatures: ['fmt.Errorf FORMAT [INPUT]']
relatedFunctions:
- fmt.Errorf
- fmt.Erroridf
- fmt.Warnf
aliases: [/functions/errorf]
---
The documentation for [Go's fmt package] describes the structure and content of the format string.
{{% include "functions/fmt/_common/fmt-layout.md" %}}
Like the [`printf`] function, the `errorf` function evaluates the format string. It then prints the result to the ERROR log and fails the build. Hugo prints each unique message once to avoid flooding the log with duplicate errors.
The `errorf` function evaluates the format string, then prints the result to the ERROR log and fails the build.
```go-html-template
{{ errorf "The %q shortcode requires a src parameter. See %s" .Name .Position }}
@@ -29,5 +24,3 @@ Like the [`printf`] function, the `errorf` function evaluates the format string
Use the [`erroridf`] function to allow optional suppression of specific errors.
[`erroridf`]: /functions/fmt/erroridf
[`printf`]: /functions/fmt/printf
[Go's fmt package]: https://pkg.go.dev/fmt

View File

@@ -1,28 +1,21 @@
---
title: fmt.Erroridf
linkTitle: erroridf
description: Log a suppressable ERROR from a template.
categories: [functions]
categories: []
keywords: []
menu:
docs:
parent: functions
function:
action:
aliases: [erroridf]
related:
- functions/fmt/Errorf
- functions/fmt/Warnf
returnType: string
signatures: ['fmt.Erroridf ID FORMAT [INPUT]']
relatedFunctions:
- fmt.Errorf
- fmt.Erroridf
- fmt.Warnf
aliases: [/functions/erroridf]
---
The documentation for [Go's fmt package] describes the structure and content of the format string.
{{% include "functions/fmt/_common/fmt-layout.md" %}}
Like the [`errorf`] function, the `erroridf` function evaluates the format string, prints the result to the ERROR log, then fails the build. Hugo prints each unique message once to avoid flooding the log with duplicate errors.
Unlike the `errorf` function, you may suppress errors logged by the `erroridf` function by adding the message ID to the `ignoreErrors` array in your site configuration.
The `erroridf` function evaluates the format string, then prints the result to the ERROR log and fails the build. Unlike the [`errorf`] function, you may suppress errors logged by the `erroridf` function by adding the message ID to the `ignoreErrors` array in your site configuration.
This template code:
@@ -34,15 +27,14 @@ Produces this console log:
```text
ERROR You should consider fixing this.
If you feel that this should not be logged as an ERROR, you can ignore it by adding this to your site config:
ignoreErrors = ["error-42"]
You can suppress this error by adding the following to your site configuration:
ignoreErrors = ['error-42']
```
To suppress this message:
{{< code-toggle file=hugo copy=false >}}
{{< code-toggle file=hugo >}}
ignoreErrors = ["error-42"]
{{< /code-toggle >}}
[`errorf`]: /functions/fmt/errorf
[Go's fmt package]: https://pkg.go.dev/fmt

View File

@@ -1,25 +1,20 @@
---
title: fmt.Print
linkTitle: print
description: Prints the default representation of the given arguments using the standard `fmt.Print` function.
categories: [functions]
categories: []
keywords: []
menu:
docs:
parent: functions
function:
action:
aliases: [print]
related:
- functions/fmt/Printf
- functions/fmt/Println
returnType: string
signatures: [fmt.Print INPUT]
relatedFunctions:
- fmt.Print
- fmt.Printf
- fmt.Println
aliases: [/functions/print]
---
```go-html-template
{{ print "foo" }} → "foo"
{{ print "foo" "bar" }} → "foobar"
{{ print "foo" }} → foo
{{ print "foo" "bar" }} → foobar
{{ print (slice 1 2 3) }} → [1 2 3]
```

View File

@@ -1,26 +1,19 @@
---
title: fmt.Printf
linkTitle: printf
description: Formats a string using the standard `fmt.Sprintf` function.
categories: [functions]
categories: []
keywords: []
menu:
docs:
parent: functions
function:
action:
aliases: [printf]
related:
- functions/fmt/Print
- functions/fmt/Println
returnType: string
signatures: ['fmt.Printf FORMAT [INPUT]']
relatedFunctions:
- fmt.Print
- fmt.Printf
- fmt.Println
aliases: [/functions/printf]
---
The documentation for [Go's fmt package] describes the structure and content of the format string.
[Go's fmt package]: https://pkg.go.dev/fmt
{{% include "functions/fmt/_common/fmt-layout.md" %}}
```go-html-template
{{ $var := "world" }}

View File

@@ -1,23 +1,18 @@
---
title: fmt.Println
linkTitle: println
description: Prints the default representation of the given argument using the standard `fmt.Print` function and enforces a linebreak.
categories: [functions]
description: Prints the default representation of the given argument using the standard `fmt.Print` function and enforces a line break.
categories: []
keywords: []
menu:
docs:
parent: functions
function:
action:
aliases: [println]
related:
- functions/fmt/Print
- functions/fmt/Printf
returnType: string
signatures: [fmt.Println INPUT]
relatedFunctions:
- fmt.Print
- fmt.Printf
- fmt.Println
aliases: [/functions/println]
---
```go-html-template
{{ println "foo" }} → "foo\n"
{{ println "foo" }} → foo\n
```

View File

@@ -1,30 +1,22 @@
---
title: fmt.Warnf
linkTitle: warnf
description: Log a WARNING from a template.
categories: [functions]
categories: []
keywords: []
menu:
docs:
parent: functions
function:
action:
aliases: [warnf]
related:
- functions/fmt/Errorf
- functions/fmt/Erroridf
returnType: string
signatures: ['fmt.Warnf FORMAT [INPUT]']
relatedFunctions:
- fmt.Errorf
- fmt.Erroridf
- fmt.Warnf
aliases: [/functions/warnf]
---
The documentation for [Go's fmt package] describes the structure and content of the format string.
{{% include "functions/fmt/_common/fmt-layout.md" %}}
Like the [`printf`] function, the `warnf` function evaluates the format string. It then prints the result to the WARNING log. Hugo prints each unique message once to avoid flooding the log with duplicate warnings.
The `warnf` function evaluates the format string, then prints the result to the WARNING log. Hugo prints each unique message once to avoid flooding the log with duplicate warnings.
```go-html-template
{{ warnf "Copyright notice missing from site configuration" }}
{{ warnf "The %q shortcode was unable to find %s. See %s" .Name $file .Position }}
```
[`printf`]: /functions/fmt/printf
[Go's fmt package]: https://pkg.go.dev/fmt

View File

@@ -0,0 +1,13 @@
---
cascade:
_build:
list: never
publishResources: false
render: never
---
<!--
Files within this headless branch bundle are markdown snippets. Each file must contain front matter delimiters, though front matter fields are not required.
Include the rendered content using the "include" shortcode.
-->

View File

@@ -0,0 +1,7 @@
---
# Do not remove front matter.
---
The documentation for Go's [fmt] package describes the structure and content of the format string.
[fmt]: https://pkg.go.dev/fmt

View File

@@ -0,0 +1,12 @@
---
title: Fmt functions
linkTitle: fmt
description: Template functions to print strings within a template or to print messages to the terminal
categories: []
keywords: []
menu:
docs:
parent: functions
---
Use these functions to print strings within a template or to print messages to the terminal.