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: accept interface values as valid #3642

Closed
ugorji opened this issue May 18, 2012 · 2 comments
Closed

text/template: accept interface values as valid #3642

ugorji opened this issue May 18, 2012 · 2 comments

Comments

@ugorji
Copy link
Contributor

@ugorji ugorji commented May 18, 2012

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.
@ugorji
Copy link
Contributor Author

@ugorji ugorji commented May 18, 2012

Comment 1:

Enter Fix candidate CL: http://golang.org/cl/6218052
@robpike
Copy link
Contributor

@robpike robpike commented May 22, 2012

Comment 2:

This issue was closed by revision 4f7c33c.

Status changed to Fixed.

@ugorji ugorji added fixed labels May 22, 2012
robpike added a commit that referenced this issue May 11, 2015
…e as valid.

««« backport 4c05c319570b
text/template: exec should accept interface value as valid.

Currently, if you pass some data to a template as an interface (e.g. interface{})
and extract that value that value as a parameter for a function, it fails, saying
wrong type.

This is because it is only looking at the interface type, not the interface content.

This CL uses the underlying content as the parameter to the func.

Fixes #3642.

R=golang-dev, r, r
CC=golang-dev
https://golang.org/cl/6218052

»»»
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.