-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
This is potentially related to #16912. I couldn't really find explicit documentation on template redefinition, and any limitations/restrictions on it.
From looking around the CL that implemented it and its commit message, it made it sound like it should be possible to simply redefine any template by defining it again, and then have it take on the new template content.
In other words, I expected a template redefined to new content X to behave as if it were a template first created with content X. This turned out not to be the case for some content X (so far, it happens when content is empty or contains whitespace and template comments only).
-
What version of Go are you using (
go version)?go version devel +2f679d7 Sun Aug 28 21:38:09 2016 +0000 linux/amd64(That's the latest
tipcommit 2f679d7 from a day ago as of posting this.)I initially ran into this issue on Go 1.7, but I tried it on latest
tipin order to check if it has since been fixed or not. It's not. -
What operating system and processor architecture are you using (
go env)?$ go env GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/ubuntu/GoPath" GORACE="" GOROOT="/home/ubuntu/go" GOTOOLDIR="/home/ubuntu/go/pkg/tool/linux_amd64" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build390318819=/tmp/go-build -gno-record-gcc-switches" CXX="g++" CGO_ENABLED="1" -
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.I redefined a template with an empty template, or a template consisting of whitespace (and template comments).
-
What did you expect to see?
Names: - Gamora - Groot - Nebula - Rocket - Star-Lord Names:Names: -
What did you see instead?
The template redefinition was effectively ignored. No error, and the old template contents were still used.
Names: - Gamora - Groot - Nebula - Rocket - Star-Lord Names: - Gamora - Groot - Nebula - Rocket - Star-Lord Names: - Gamora - Groot - Nebula - Rocket - Star-LordIf you include any non-whitespace character in the redefined template content, such as
x, then it works as expected, e.g.:Names: - Gamora - Groot - Nebula - Rocket - Star-Lord Names:xNames:x