commit | 618f88d847af9a060a14794859d4f1ea51a08006 | [log] [tgz] |
---|---|---|
author | Daniel Martí <mvdan@mvdan.cc> | Sun Dec 17 22:32:15 2017 +0000 |
committer | Daniel Martí <mvdan@mvdan.cc> | Tue Feb 13 22:18:21 2018 +0000 |
tree | 0f8ecfedc871e621f62720e08977a16376eeb786 | |
parent | 0ed5bec951e3068df3201254f615b5ad1d429ee0 [diff] |
text/template: never call reflect.Zero(nil) It makes no sense to try to get the zero value of a nil type, hence the panic. When we have a nil type, use reflect.ValueOf(nil) instead. This was showing itself if one used a missing field on the data between parentheses, when the data was a nil interface: t := template.Must(template.New("test").Parse(`{{ (.).foo }}`)) var v interface{} t.Execute(os.Stdout, v) Resulting in: panic: reflect: Zero(nil) [recovered] panic: reflect: Zero(nil) Fixes #21171. Change-Id: Ifcc4a0c67e6df425b65bc9f82fde6fcf03828579 Reviewed-on: https://go-review.googlesource.com/84482 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 3.0 Attributions license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Official binary distributions are available at https://golang.org/dl/.
After downloading a binary release, visit https://golang.org/doc/install or load doc/install.html in your web browser for installation instructions.
If a binary distribution is not available for your combination of operating system and architecture, visit https://golang.org/doc/install/source or load doc/install-source.html in your web browser for source installation instructions.
Go is the work of hundreds of contributors. We appreciate your help!
To contribute, please read the contribution guidelines: https://golang.org/doc/contribute.html
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://golang.org/wiki/Questions for a list of places to ask questions about the Go language.