Skip to content

text/template: Functions are evaluated immediately and  #16125

@aarondl

Description

@aarondl

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go version 1.6.2 linux/amd64
  2. What operating system and processor architecture are you using (go env)?
    Ubuntu 16.04 Xenial - Linux, amd64
  3. 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.
    https://play.golang.org/p/zbRIyl8apl
  4. What did you expect to see?
    I expected the function toupper to be passed as an argument to map and for the output of the program to be like this one https://play.golang.org/p/S8LsA-o5KX
  5. What did you see instead?
template: :1:10: executing "" at <toupper>: wrong number of args for toupper: want 1 got 0

It seems like toupper is evaluated as soon as it's seen, which breaks because it's meant to be an argument to the map function.

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