You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
1. Create two templates in a set
2. both should contain "{{define "foo"}}...{{end}}"
(see example program below)
What is the expected output?
template: redefinition of template "foo"
What do you see instead?
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x10 pc=0x424360]
goroutine 1 [running]:
text/template.(*Template).associate(0xf840020100, 0xf840020140, 0x7f3f00000004,
0xf840020140, 0x0, ...)
/home/christoph/Development/go/src/pkg/text/template/template.go:201 +0x103
text/template.(*Template).Parse(0xf840020100, 0x4d8c6c, 0x6c706d7400000026,
0xf840020100, 0x0, ...)
/home/christoph/Development/go/src/pkg/text/template/template.go:181 +0x23d
main.main()
/home/christoph/gopath/src/test/test.go:18 +0x1dc
Which compiler are you using (5g, 6g, 8g, gccgo)?
6g
Which operating system are you using?
Linux tuxmobil 3.1.8-2.fc16.x86_64 #1 SMP Sat Jan 7 13:35:24 UTC 2012 x86_64 x86_64
x86_64 GNU/Linux
Which revision are you using? (hg identify)
0640cfa9d9cf tip
Please provide any additional information below.
package main
import (
"log"
"os"
"text/template"
)
var tmplText1 string = `template 1 {{define "test"}}foo{{end}}`
var tmplText2 string = `template 2 {{define "test"}}bar{{end}}`
func main() {
var tmpl *template.Template
var err error
if tmpl, err = template.New("tmpl1").Parse(tmplText1); err != nil {
log.Fatalf("Parse 1: %v", err)
}
if _, err = tmpl.New("tmpl2").Parse(tmplText2); err != nil {
log.Fatalf("Parse 2: %v", err)
}
if err = tmpl.ExecuteTemplate(os.Stdout, "tmpl1", nil); err != nil {
log.Fatalf("ExecuteTemplate: %v", err)
}
}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: