Text and HTML templates / if action / Essential Go

Run Settings
LanguageGo
Language Version
Run Command
package main import ( "log" "os" "text/template" ) const tmplStr = `{{range . -}} {{if .IsNew}}'{{.Name}}' is new{{else}}'{{.Name}}' is not new{{end}} {{end}}` func main() { t := template.Must(template.New("if").Parse(tmplStr)) data := []struct { Name string IsNew bool }{ {"Bridge", false}, {"Electric battery", true}, } err := t.Execute(os.Stdout, data) if err != nil { log.Fatalf("t.Execute() failed with '%s'\n", err) } }
Editor Settings
Theme
Key bindings
Full width
Lines