-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
What version of Go are you using (go version)?
go1.7 darwin/amd64
What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOOS="darwin"
What did you do?
Parse and execute this template
Research Grants {{range Block "Research Funding History"}} {{.Emit "Funding Start Date, Funding End Date, Funding Title"-}} {{range .SubSection "Funding Sources" }} {{.Emit "Program Name, Funding Organization" -}} {{end}} {{end}}
What did you expect to see?
white space trimmed
What did you see instead?
SEGV (see below) in several scenarios eg this crashes
{{.Emit "Funding Start Date, Funding End Date, Funding Title"-}}
but not this one
{{.Emit "Funding Start Date, Funding End Date, Funding Title" -}}
Notice space before -}}
Also, SEGV when adding - to {{end}} eg {{-end}} or {{end-}}
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0xed934]
goroutine 3 [running]:
panic(0x1a25a0, 0xc42000a090)
/Users/salah/go/src/runtime/panic.go:500 +0x1a1
testing.tRunner.func1(0xc4200a4180)
/Users/salah/go/src/testing/testing.go:579 +0x25d
panic(0x1a25a0, 0xc42000a090)
/Users/salah/go/src/runtime/panic.go:458 +0x243
html/template.(*Template).escape(0x0, 0x0, 0x0)
/Users/salah/go/src/html/template/template.go:79 +0x44
html/template.(*Template).Execute(0x0, 0x2a7840, 0xc420086008, 0x18e3e0, 0xc4200740c0, 0xc42000b160, 0xc420124200)
/Users/salah/go/src/html/template/template.go:101 +0x2f
salah/CCV/template.TestGoTemplate(0xc4200a4180)
/Users/salah/Dropbox/code/go/src/salah/CCV/template/template_test.go:117 +0x45e
testing.tRunner(0xc4200a4180, 0x1ecae0)
Edit:
managed to replicate the error here https://play.golang.org/p/V6VoOm_tWR
the error occurs with Output 1: {{title . | printf "%q"-}}
but not with this one "{{23 -}} < {{ "test"-}}"