package main import ( "fmt" "html/template" "log" "os" ) type link struct { Text string Href string } func main() { const tpl = ` {{.Title}}

{{.Title}}

{{.Body}}

{{range .Items}}
{{ .Text }}
{{else}}
no rows
{{end}}
` check := func(err error) { if err != nil { log.Fatal(err) } } t, err := template.New("webpage").Parse(tpl) check(err) appName := os.Getenv("FN_APP_NAME") data := struct { Title string Body string Items []link }{ Title: "My App", Body: "This is my app. It may not be the best app, but it's my app. And it's multilingual!", Items: []link{ link{"Ruby", fmt.Sprintf("/r/%s/ruby", appName)}, link{"Node", fmt.Sprintf("/r/%s/node", appName)}, link{"Python", fmt.Sprintf("/r/%s/python", appName)}, }, } err = t.Execute(os.Stdout, data) check(err) }