Skip to content

text/template: documentation for IsTrue disagrees with its implementation for struct types #28394

@bcmills

Description

@bcmills

As noted in #28391, the documentation for template.IsTrue says:

IsTrue reports whether the value is 'true', in the sense of not the zero of its type, and whether the value has a meaningful truth value.

The zero time.Time is the zero of its type, so according to the documentation it should be considered to be true, but the implementation clearly intends otherwise:

case reflect.Struct:
truth = true // Struct values are always true.

Either the documentation should be clarified, or the behavior of IsTrue should be fixed to match what is documented. Probably the former.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.NeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions