strings.Chomp
Returns the given string, removing all trailing newline characters and carriage returns.
- Syntax
- strings.Chomp STRING
- Returns
- any
- Alias
- chomp
Usage
The strings.Chomp function returns the given string, removing all trailing newline characters and carriage returns. If STRING is of type template.HTML, the function returns template.HTML, otherwise it returns a string.
Examples
{{ strings.Chomp "foo\n" }} → foo
{{ strings.Chomp "foo\n\n" }} → foo
{{ strings.Chomp "foo\r\n" }} → foo
{{ strings.Chomp "foo\r\n\r\n" }} → fooLast updated:
October 28, 2026
:
content: Apply style guide to strings functions (d6de31ebd)
Improve this page