Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

text/template

The New call gets a string that becomes the name of this template. I am not sure where is that name used again.

package main

import (
	"os"
	"text/template"
)

func main() {
	tmpl, err := template.New("test").Parse("Hello World!\n")
	if err != nil {
		panic(err)
	}
	err = tmpl.Execute(os.Stdout, nil)
	if err != nil {
		panic(err)
	}
}