-
Notifications
You must be signed in to change notification settings - Fork 18k
text/template: slice builtin does not work with arrays as described in documentation #39596
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
Comments
The pointer to array case can be resolved by inserting the following code into
|
The plain array case does work if I put the array in a struct and pass a pointer to the struct: https://play.golang.org/p/cSRHe8MN3wS However still does not work if the struct contains a pointer to an array whereas the documentation implies it should. |
@duncanharris that sounds like the right fix to me. Want to send a CL with tests? |
@mvdan Can you change the labels on this (remove NeedsInvestigation, add NeedsFix?) and assign to me? |
Done. |
Change https://golang.org/cl/318769 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Tried to use an array with the
text/template
builtinslice
function.https://play.golang.org/p/lrdcuk7gkvU
Docs at https://golang.org/pkg/text/template/ say:
and
Note that the builtin
index
function plays fine with arrays in both cases:https://play.golang.org/p/DEeEWit74YL
What did you expect to see?
output in at least one of the cases
What did you see instead?
The text was updated successfully, but these errors were encountered: