The subject of this section will probably surprise you in a good way, because both presented packages give you so much flexibility that I am sure you will find many creative ways to use them. Templates are mainly used for separating the formatting part and the data part of the output. Please note that a Go template can be either a file or a string – the general idea is to use inline strings for smaller templates and external files for bigger ones.
You cannot import both text/template and html/template on the same Go program because these two packages share the same package name (template). If absolutely necessary, you should define an alias for one of them. See the useStrings.go code in Chapter 4, The Uses of Composite Types.
Text output is usually presented on your screen, whereas HTML output is seen with the help of a web browser. However, as text...