PANIC: runtime error: invalid memory address or nil pointer dereference
goroutine 26 [running]:
github.com/codegangsta/negroni.func·003()
/Users/StephMacbook/Workarea/Go/src/github.com/codegangsta/negroni/recovery.go:34 +0x10d
html/template.(*Template).escape(0xc208147440, 0x0, 0x0)
/usr/local/Cellar/go/1.4.2/libexec/src/html/template/template.go:59 +0xe4
html/template.(*Template).Execute(0xc208147440, 0x836db8, 0xc208010d20, 0x390920, 0xc2081473e0, 0x0, 0x0)
/usr/local/Cellar/go/1.4.2/libexec/src/html/template/template.go:75 +0x3dHere is the code:
var doc bytes.Buffer
var err error
t := template.New("emailTemplate") //create a new template
t, err = t.ParseFiles("templates/" + templateName + ".html") //open and parse a template html file
//t, err = t.Parse(resetPasswordEmail)
if err != nil {
fmt.Println("Error parsing template ", err.Error())
}
err = t.Execute(&doc, data) //merge template ‘t’ with content
if err != nil {
fmt.Println("Error executing template ", err.Error())
}The panic is a bug that's fixed for go1.5.
You're actually creating 2 templates here under "t", one called emailTemplate which is empty, and one with the name of your template file. You either need to use the same name for both, or call ExecuteTemplate with the proper template name.
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/vmZHHfLsH8M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.