diff options
author | Daniel Martí <mvdan@mvdan.cc> | 2019-04-16 22:13:47 +0900 |
---|---|---|
committer | Daniel Martí <mvdan@mvdan.cc> | 2019-06-07 13:56:20 +0000 |
commit | eb2fabf2fa4e1cb0386ae52e041c3d6b0ced3d29 (patch) | |
tree | 3f83a7999c7eebc2bfde487cae9b3db8fd799efb /src/text | |
parent | 7647fcd39292b5d36eb0f0be9750eecb03b1874c (diff) | |
download | go-eb2fabf2fa4e1cb0386ae52e041c3d6b0ced3d29.tar.gz go-eb2fabf2fa4e1cb0386ae52e041c3d6b0ced3d29.zip |
text/template: clarify the safety of Template.New
In particular, the returned template isn't independent from the parent.
For example, it can't be parsed concurrently with other children
templates. Only methods which are explicitly safe for concurrent use,
like Execute, may be used concurrently.
Fixes #30281.
Change-Id: Idc84bf4199c035316cdb83b950fd4a8f2a71cd0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/172297
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
Diffstat (limited to 'src/text')
-rw-r--r-- | src/text/template/template.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/text/template/template.go b/src/text/template/template.go index 41cdd5682c..1135d819b9 100644 --- a/src/text/template/template.go +++ b/src/text/template/template.go @@ -50,6 +50,10 @@ func (t *Template) Name() string { // New allocates a new, undefined template associated with the given one and with the same // delimiters. The association, which is transitive, allows one template to // invoke another with a {{template}} action. +// +// Because associated templates share underlying data, template construction +// cannot be done safely in parallel. Once the templates are constructed, they +// can be executed in parallel. func (t *Template) New(name string) *Template { t.init() nt := &Template{ |