Skip to content

text/template: accept interface values as valid #3642

@ugorji

Description

@ugorji
Before filing a bug, please check whether it has been fixed since the
latest release. Search the issue tracker and check that you're running the
latest version of Go:

Run "go version" and compare against
http://golang.org/doc/devel/release.html  If a newer version of Go exists,
install it and retry what you did to reproduce the problem.

Thanks.

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1.
2.
3.

Pass a valid value into the template as an interface{} (or other interface value).
Try to use it as a parameter to a function later.
It fails because validateType doesn't account for interface values 
(it only accounts for dereferencing pointers).

See: http://play.golang.org/p/Hzf2xal82F

What is the expected output?
From MyLog: Some Message

What do you see instead?
Err: template: t1:1: wrong type for value; expected string; got interface {}

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
Linux

Which version are you using?  (run 'go version')


Please provide any additional information below.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions