August 2019
Beginner to intermediate
798 pages
17h 2m
English
If you need to create plain text output, then using the text/template package is a good choice. The use of the text/template package will be illustrated in textT.go, which will be presented in five parts.
As templates are usually stored in external files, the example presented will use the text.gotext template file, which will be analyzed in three parts. Data is typically read from text files or from the Internet. However, for reasons of simplicity, the data for textT.go will be hardcoded in the program using a slice.
We will start by looking at the Go code of textT.go. The first code portion of textT.go is as follows:
package main
import (
"fmt"
"os"
"text/template"
)
The second code segment from textT.go is as follows: ...
Read now
Unlock full access