Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text/template: misleading error in template: "nil pointer" on typo #15125

Closed
boslandm opened this issue Apr 5, 2016 · 2 comments
Closed

text/template: misleading error in template: "nil pointer" on typo #15125

boslandm opened this issue Apr 5, 2016 · 2 comments
Milestone

Comments

@boslandm
Copy link

boslandm commented Apr 5, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?

go1.6

  1. What operating system and processor architecture are you using (go env)?

Playground, also reproduced on
GOHOSTARCH="amd64"
GOHOSTOS="linux"

  1. What did you do?
    If possible, provide a recipe for reproducing the error.
    A complete runnable program is good.
    A link on play.golang.org is best.

http://play.golang.org/p/fjDUgnco1F

  1. What did you expect to see?

A type has definite members. If a member is being requested that does not exist for that type the template should return a no type found error, even if the value of the type is nil.

  1. What did you see instead?

Executing a template with a typo on a nil struct gives the misleading error that the struct is nil. This is true but the real error is that no member can be found.

template: tmpl:1:2: executing "tmpl" at <.Get>: nil pointer evaluating *main.outer.Get
template: tmpl:1:2: executing "tmpl" at <.Get>: Get is not a field of struct type struct {}

@bradfitz bradfitz changed the title Misleading error in template: "nil pointer" on typo text/template: misleading error in template: "nil pointer" on typo Apr 7, 2016
@bradfitz bradfitz added this to the Go1.7 milestone Apr 7, 2016
@gopherbot
Copy link

CL https://golang.org/cl/21705 mentions this issue.

@gopherbot
Copy link

CL https://golang.org/cl/23062 mentions this issue.

@golang golang locked and limited conversation to collaborators May 11, 2017
@rsc rsc unassigned adg Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants