I have Files
slice of File
structure in my Go program to keep name and size of files. I created template, see below:
type File struct {
FileName string
FileSize int64
}
var Files []File
const tmpl = `
{{range .Files}}
file {{.}}
{{end}}
`
t := template.Must(template.New("html").Parse(tmplhtml))
err = t.Execute(os.Stdout, Files)
if err != nil { panic(err) }
Of course I got panic saying:
can't evaluate field Files in type []main.File
Not sure how to correctly display file names and sizes using range
in template.