why dash is used in condition Go templates

Dash removes the spaces from the output on the side it appears in the template:

https://golang.org/pkg/text/template/#hdr-Text_and_spaces

{{- if ...}}

The above will remove all spaces that appear before the if statement, so if the result of if prints something, it’ll be right after the last piece of text without any spaces.

Leave a Comment