When you say {{range .Chunk}}, the template is essentially attempting to run for _, x := range d.Chunk but you cannot do that because you can only range over arrays, maps or slices. You can instead range over d.Chunk.ChunkData, d.Chunk.ChunkId and/or d.Chunk.ChunkId with {{range .Chunk.ChunkData}}, etc.
You could change your type definitions to something like this:
type Chunk struct {
ChunkedData []string
User string
ChunkId int
}
type Chunks []Chunk
///Sruct comprising of both Chunks struct and HeaderFooter struct.
///This struct is to be passed to the html template
type Data struct {
Chunks
HF HeaderFooter
}
Or if you keep your existing types, if I can assume that the indexes into the ChunkedData, Users and ChunkId slices are related (i.e. d.Chunk.ChunkedData[5] is related to d.Chunk.Users[5] and d.Chunk.ChunkId[5], etc.), then you could change your template to this:
The plain {{range .Chunk}} pulls the values out of .Chunk and changes the scope of the actions within the {{range}}, so that . now refers to those values. When you add in the variables, {{range $index, $chunk := .Chunk}} it works just like a for index, chunk := range d.Chunk loop. Now that you have an index, you can index into the other slices within d.Chunk. The way you do d.Chunk.Users[index] in Go’s template syntax is {{index .Chunk.Users $index}}