]> Cypherpunks repositories - gostls13.git/commitdiff
text/template: say more often that templates are safe for parallel execution
authorRob Pike <r@golang.org>
Tue, 15 Apr 2014 15:48:40 +0000 (08:48 -0700)
committerRob Pike <r@golang.org>
Tue, 15 Apr 2014 15:48:40 +0000 (08:48 -0700)
It was said already but apparently not enough times.

Fixes #6985.

LGTM=crawshaw
R=golang-codereviews, crawshaw
CC=golang-codereviews
https://golang.org/cl/86300043

src/pkg/html/template/template.go
src/pkg/text/template/doc.go
src/pkg/text/template/exec.go

index 11cc34a50a38eb80297d54da58808bbe39c07625..744f139ba4417bfdae5762055ea8f83092067b74 100644 (file)
@@ -62,6 +62,7 @@ func (t *Template) escape() error {
 
 // Execute applies a parsed template to the specified data object,
 // writing the output to wr.
+// A template may be executed safely in parallel.
 func (t *Template) Execute(wr io.Writer, data interface{}) error {
        if err := t.escape(); err != nil {
                return err
@@ -71,6 +72,7 @@ func (t *Template) Execute(wr io.Writer, data interface{}) error {
 
 // ExecuteTemplate applies the template associated with t that has the given
 // name to the specified data object and writes the output to wr.
+// A template may be executed safely in parallel.
 func (t *Template) ExecuteTemplate(wr io.Writer, name string, data interface{}) error {
        tmpl, err := t.lookupAndEscapeTemplate(name)
        if err != nil {
index f622ac7dcee2019e82ad0cf3dbd7829f78a75236..7c6efd59cded112d1f201bc5e805a43c7279e3d1 100644 (file)
@@ -20,7 +20,7 @@ The input text for a template is UTF-8-encoded text in any format.
 "{{" and "}}"; all text outside actions is copied to the output unchanged.
 Actions may not span newlines, although comments can.
 
-Once constructed, a template may be executed safely in parallel.
+Once parsed, a template may be executed safely in parallel.
 
 Here is a trivial example that prints "17 items are made of wool".
 
index 6de37a19963f35a3c345b549f979e34babc42d36..505509a08540724c474d10970593ee0b36abfeb1 100644 (file)
@@ -108,6 +108,7 @@ func errRecover(errp *error) {
 
 // ExecuteTemplate applies the template associated with t that has the given name
 // to the specified data object and writes the output to wr.
+// A template may be executed safely in parallel.
 func (t *Template) ExecuteTemplate(wr io.Writer, name string, data interface{}) error {
        tmpl := t.tmpl[name]
        if tmpl == nil {
@@ -118,6 +119,7 @@ func (t *Template) ExecuteTemplate(wr io.Writer, name string, data interface{})
 
 // Execute applies a parsed template to the specified data object,
 // and writes the output to wr.
+// A template may be executed safely in parallel.
 func (t *Template) Execute(wr io.Writer, data interface{}) (err error) {
        defer errRecover(&err)
        value := reflect.ValueOf(data)