-
Notifications
You must be signed in to change notification settings - Fork 18.8k
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
Given:
package main
import (
"html/template"
"os"
)
func main() {
m := make(map[template.HTML]string)
m["Key"] = "Val"
// OK!
if _, ok := m["Key"]; !ok {
panic("Map lookup failed")
}
t, err := template.New("foo").Parse(data)
if err != nil {
panic(err)
}
// This fails
err = t.Execute(os.Stdout, m)
if err != nil {
panic(err)
}
}
var data = `{{ index . "Key" }}`This panics:
panic: template: foo:1:3: executing "foo" at <index . "Key">: error calling index: value has type string; should be template.HTML
Juggling around with template.HTML and string types seems like a common thing in Go templates, and I would expect the index func to work the same way as a straight map lookup in this case.
willfaught
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.