Go Text + HTML Templating Multiple item template

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!


Note the use of {{range .}} and {{end}} to cycle over the collection.

package main

import (

func main() {
    const (
        letter = `Dear {{range .}}{{.}}, {{end}} How are you?`

    tmpl, err := template.New("letter").Parse(letter)
    if err != nil {

    tmpl.Execute(os.Stdout, []string{"Harry", "Jane", "Lisa", "George"})

Results in:

Dear Harry, Jane, Lisa, George,  How are you?

Got any Go Question?