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
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.
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 {}
The text was updated successfully, but these errors were encountered:
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
Please answer these questions before submitting your issue. Thanks!
go version
)?go1.6
go env
)?Playground, also reproduced on
GOHOSTARCH="amd64"
GOHOSTOS="linux"
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
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.
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 {}
The text was updated successfully, but these errors were encountered: