Commit eb5925f5 authored by Daniel Martí's avatar Daniel Martí

text/template: remove associate's error return

It's always nil, so simplify its signature. Found with unparam.

Change-Id: I45dd0f868ec2f5de98a970776be686417c8d73b6
Reviewed-on: https://go-review.googlesource.com/95235
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent b657c002
...@@ -125,9 +125,8 @@ func (t *Template) AddParseTree(name string, tree *parse.Tree) (*Template, error ...@@ -125,9 +125,8 @@ func (t *Template) AddParseTree(name string, tree *parse.Tree) (*Template, error
nt = t.New(name) nt = t.New(name)
} }
// Even if nt == t, we need to install it in the common.tmpl map. // Even if nt == t, we need to install it in the common.tmpl map.
if replace, err := t.associate(nt, tree); err != nil { replace := t.associate(nt, tree)
return nil, err if replace || nt.Tree == nil {
} else if replace || nt.Tree == nil {
nt.Tree = tree nt.Tree = tree
} }
return nt, nil return nt, nil
...@@ -212,15 +211,15 @@ func (t *Template) Parse(text string) (*Template, error) { ...@@ -212,15 +211,15 @@ func (t *Template) Parse(text string) (*Template, error) {
// associate installs the new template into the group of templates associated // associate installs the new template into the group of templates associated
// with t. The two are already known to share the common structure. // with t. The two are already known to share the common structure.
// The boolean return value reports whether to store this tree as t.Tree. // The boolean return value reports whether to store this tree as t.Tree.
func (t *Template) associate(new *Template, tree *parse.Tree) (bool, error) { func (t *Template) associate(new *Template, tree *parse.Tree) bool {
if new.common != t.common { if new.common != t.common {
panic("internal error: associate not common") panic("internal error: associate not common")
} }
if old := t.tmpl[new.name]; old != nil && parse.IsEmptyTree(tree.Root) && old.Tree != nil { if old := t.tmpl[new.name]; old != nil && parse.IsEmptyTree(tree.Root) && old.Tree != nil {
// If a template by that name exists, // If a template by that name exists,
// don't replace it with an empty template. // don't replace it with an empty template.
return false, nil return false
} }
t.tmpl[new.name] = new t.tmpl[new.name] = new
return true, nil return true
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment