Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html/template: Parse overrides templates with empty templates #19204

Closed
DDRBoxman opened this issue Feb 20, 2017 · 4 comments
Closed

html/template: Parse overrides templates with empty templates #19204

DDRBoxman opened this issue Feb 20, 2017 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@DDRBoxman
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

1.8

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/ddrboxman/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/hf/vcfpg1rd77qdcxmt5dwqr2nw0000gn/T/go-build688954702=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

https://play.golang.org/p/xsexXsdE5x

What did you expect to see?

2009/11/10 23:00:00
placeholder

What did you see instead?

2009/11/10 23:00:00

Other Info

https://golang.org/pkg/html/template/#Template.Parse
"A template definition with a body containing only white space and comments is considered empty and will not replace an existing template's body"

@josharian josharian changed the title html/template Parse overrides templates with empty templates. html/template: parse overrides templates with empty templates Feb 20, 2017
@josharian josharian changed the title html/template: parse overrides templates with empty templates html/template: Parse overrides templates with empty templates Feb 20, 2017
@bradleypeabody
Copy link

bradleypeabody commented Feb 22, 2017

One other important point on this issue is that the behavior is not consistent. I ran into this same issue separately and made this example: https://play.golang.org/p/mpBOEdhkFR Both playground examples exhibit different behavior if you open it, add a space somewhere (to force a cache miss), and hit run again. Do that about 10-20 times and you should get at least one or two times where it produces a different result. Some sort of race condition happening here. I also verified my example works correctly on go 1.7.5 and exhibits the buggy behavior described with the go 1.8 download.

@bradfitz bradfitz added this to the Go1.9Maybe milestone Mar 21, 2017
@bradfitz bradfitz added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 21, 2017
@robpike
Copy link
Contributor

robpike commented Mar 22, 2017

This has been fixed by recent changes, most likely https://go-review.googlesource.com/c/38420/ (soon to be submitted).

@robpike robpike closed this as completed Mar 22, 2017
@robpike robpike reopened this Mar 22, 2017
@gopherbot
Copy link

CL https://golang.org/cl/38420 mentions this issue.

@gopherbot
Copy link

CL https://golang.org/cl/39594 mentions this issue.

gopherbot pushed a commit that referenced this issue Apr 5, 2017
This was a subtle bug introduced in the previous release's fix for
issue 16156.

The definition of empty template was broken, causing the answer
to depend on the order of templates in the map.

Fixes #16156 (for real).
Fixes #19294.
Fixes #19204.

Change-Id: I1cd915c94534cad3116d83bd158cbc28700510b9
Reviewed-on: https://go-review.googlesource.com/38420
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-on: https://go-review.googlesource.com/39594
Reviewed-by: Rob Pike <r@golang.org>
lparth pushed a commit to lparth/go that referenced this issue Apr 13, 2017
This was a subtle bug introduced in the previous release's fix for
issue 16156.

The definition of empty template was broken, causing the answer
to depend on the order of templates in the map.

Fixes golang#16156 (for real).
Fixes golang#19294.
Fixes golang#19204.

Change-Id: I1cd915c94534cad3116d83bd158cbc28700510b9
Reviewed-on: https://go-review.googlesource.com/38420
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Apr 5, 2018
@rsc rsc unassigned robpike Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants