-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
34 lines (28 loc) · 820 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"fmt"
gout "github.com/drewstinnett/gout/v2"
"github.com/drewstinnett/gout/v2/formats/gotemplate"
)
type sample struct {
FirstName string
LastName string
Age int
}
type sampleList []sample
func main() {
people := &sampleList{
sample{FirstName: "Jason", LastName: "Vorhees", Age: 11},
sample{FirstName: "Freddy", LastName: "Krueger", Age: 35},
sample{FirstName: "Michael", LastName: "Myers", Age: 13},
}
g := gout.New()
g.SetFormatter(gotemplate.Formatter{
Template: "{{ range . }}{{ .FirstName }} {{ .LastName }} is {{ .Age }} years old\n{{ end }}",
})
//"template": "{{ range . }}{{ .FirstName }} {{ .LastName }} is {{ .Age }} years old\n{{ end }}",
fmt.Printf("# Format: gotemplate\n## People\n")
g.MustPrint(people)
fmt.Println()
// fmt.Println(string(b))
}