]> Cypherpunks repositories - gostls13.git/commitdiff
template: explain that fields must be exported.
authorRob Pike <r@golang.org>
Thu, 2 Jun 2011 14:09:42 +0000 (00:09 +1000)
committerRob Pike <r@golang.org>
Thu, 2 Jun 2011 14:09:42 +0000 (00:09 +1000)
Fixes #1792.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4548083

src/pkg/template/template.go

index 1011190044509554be483e02b6bc252b91ba25ec..f481cbd1ee36e7b455adf3099d0006b358e8d5ab 100644 (file)
        Data items may be values or pointers; the interface hides the
        indirection.
 
-       In the following, 'field' is one of several things, according to the data.
+       In the following, 'Field' is one of several things, according to the data.
 
-               - The name of a field of a struct (result = data.field),
-               - The value stored in a map under that key (result = data[field]), or
+               - The name of a field of a struct (result = data.Field),
+               - The value stored in a map under that key (result = data["Field"]), or
                - The result of invoking a niladic single-valued method with that name
-                 (result = data.field())
+                 (result = data.Field())
+
+       If Field is a struct field or method name, it must be an exported
+       (capitalized) name.
 
        Major constructs ({} are the default delimiters for template actions;
        [] are the notation in this comment for optional elements):