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 with map

package main

import (
	"os"
	"text/template"
)

func main() {
	person := map[string]string{
		"Name": "Joe",
	}
	tmpl, err := template.New("test").Parse("Hello {{.Name}}\n")
	if err != nil {
		panic(err)
	}
	err = tmpl.Execute(os.Stdout, person)
	if err != nil {
		panic(err)
	}
}