Repository: go
Issue: text/template: Clone() does not clone options like it does for funcs
Labels: NeedsInvestigation

<!--
Please answer these questions before submitting your issue. Thanks!
For questions please use one of our forums: https://github.com/golang/go/wiki/Questions
-->

### What version of Go are you using (`go version`)?

<pre>
$ go version
go version go1.15.4 darwin/amd64
</pre>

### Does this issue reproduce with the latest release?
Yes


### What operating system and processor architecture are you using (`go env`)?

<details><summary><code>go env</code> Output</summary><br><pre>
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/bokwoon/Library/Caches/go-build"
GOENV="/Users/bokwoon/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/bokwoon/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/bokwoon/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/bokwoon/Documents/nusskylabx/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/dz/0qq60fyd6z3dbr2qqy23mfpm0000gn/T/go-build334239392=/tmp/go-build -gno-record-gcc-switches -fno-common"
</pre></details>

### What did you do?

<!--
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
-->
html/template `.Clone()` method will copy the funcmap set with `.FuncMap()` over to the cloned template ([as mentioned here](https://github.com/golang/go/issues/34680#issuecomment-553536535)). However `.Clone()` does not seem to copy the [options](https://golang.org/pkg/html/template/#Template.Option) set with `.Option()` over to the cloned template. Instead the cloned template reverts back to the default option `missingkey=invalid`. Example code demonstrating how the funcmap is copied over, but the options are not:
https://play.golang.org/p/1M00gykKOkp

```go
package main

import (
	"html/template"
	"fmt"
	"os"
)

func main() {
	t1 := template.Must(template.
		New("t").
		Option("missingkey=error").
		Funcs(map[string]interface{}{
			"SomeFunc": func() string { return "template" },
		}).
		Parse(`{{SomeFunc}} {{.tmpl}}: {{.jdlsadjklja}}`),
	)
	t2 := template.Must(t1.Clone())
	
	if err := t1.Execute(os.Stdout, map[string]interface{}{"tmpl": "t1"}); err != nil {
		fmt.Printf("t1 error: %s\n", err)
	}
	if err := t2.Execute(os.Stdout, map[string]interface{}{"tmpl": "t2"}); err != nil {
		fmt.Printf("t2 error: %s\n", err)
	}
}
```

### What did you expect to see?
```
template t1: t1 error: template: t1:1:26: executing "t" at <.jdlsadjklja>: map has no entry for key "jdlsadjklja"
template t2: t2 error: template: t1:1:26: executing "t" at <.jdlsadjklja>: map has no entry for key "jdlsadjklja"
```


### What did you see instead?
```
template t1: t1 error: template: t1:1:26: executing "t" at <.jdlsadjklja>: map has no entry for key "jdlsadjklja"
template t2:
```
This behaviour is also observed for text/template, only that text/template outputs `<no value>` instead of an empty string.


Currently I am cloning a bunch of templates, and in order to preserve the options I have to store the option string somewhere in a variable and re-configure using `.Option()` on every newly cloned template. Copying options on `.Clone()` is not mentioned in the [documentation](https://golang.org/pkg/html/template/#Template.Clone), but it would be nice if it did that. Given that `.Clone()` already copies the funcmap, it seems reasonable for it to copy the options as well.