-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Milestone
Description
Note: This isn't me suggesting that you should fix this. I have had some people reporting broken Hugo sites because of this, and I was "I don't see how that can have worked" until the third person arrived with the same issue.
The program below works on Go 1.10, fails in Go 1.11:
go/bep/temp master ✗ 9m ⚑
▶ go version && go run main.go
go version go1.11.1 darwin/amd64
2018/10/27 14:02:36 template: :2:13: executing "" at <.abc>: undefined variable: $v
exit status 1
go/bep/temp master ✗ 10m ⚑ ⍉
▶ go1.10.4 version && go1.10.4 run main.go
go version go1.10.4 darwin/amd64
abcpackage main
import (
"bytes"
"fmt"
"log"
"strings"
"text/template"
)
func main() {
data := map[string]interface{}{
"abc": []string{"a", "b", "c"},
}
tpl := `
{{ range $v, .abc }}{{ $v }}{{ end }}
`
var buf bytes.Buffer
tmpl, err := template.New("").Parse(tpl)
if err != nil {
log.Fatal(err)
}
if err := tmpl.Execute(&buf, data); err != nil {
log.Fatal(err)
}
result := strings.TrimSpace(buf.String())
fmt.Println(result)
}Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.