You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
381 B
25 lines
381 B
3 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"text/template"
|
||
|
)
|
||
|
|
||
|
type Todo struct {
|
||
|
Name string
|
||
|
Url string
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
td := Todo{"Test templates", "Let's test a template to see the magic."}
|
||
|
|
||
|
t, err := template.New("todos").Parse("A radio named \"{{ .Name}}\" with url: \"{{ .Url}}\"")
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
err = t.Execute(os.Stdout, td)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
}
|