[example] fix(template(main.go)): template.ParseFiles use precise path

44 views
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
Mar 23, 2021, 4:09:22 AM3/23/21
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gerrit Bot has uploaded this change for review.

View Change

fix(template(main.go)): template.ParseFiles use precise path

only use filename will cause panic: open index.tmpl: no such file or directory

Change-Id: Ibb322c3fd85fde3d586f700cb4d6ec4acf5106f9
GitHub-Last-Rev: 4002060aa2917bc76789ee7f9b42270b01453514
GitHub-Pull-Request: golang/example#18
---
M template/main.go
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/template/main.go b/template/main.go
index 5da5475..08c3ef3 100644
--- a/template/main.go
+++ b/template/main.go
@@ -38,7 +38,7 @@
// indexTemplate is the main site template.
// The default template includes two template blocks ("sidebar" and "content")
// that may be replaced in templates derived from this one.
-var indexTemplate = template.Must(template.ParseFiles("index.tmpl"))
+var indexTemplate = template.Must(template.ParseFiles("template/index.tmpl"))

// Index is a data structure used to populate an indexTemplate.
type Index struct {
@@ -70,7 +70,7 @@

// imageTemplate is a clone of indexTemplate that provides
// alternate "sidebar" and "content" templates.
-var imageTemplate = template.Must(template.Must(indexTemplate.Clone()).ParseFiles("image.tmpl"))
+var imageTemplate = template.Must(template.Must(indexTemplate.Clone()).ParseFiles("template/image.tmpl"))

// Image is a data structure used to populate an imageTemplate.
type Image struct {

To view, visit change 303889. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: example
Gerrit-Branch: master
Gerrit-Change-Id: Ibb322c3fd85fde3d586f700cb4d6ec4acf5106f9
Gerrit-Change-Number: 303889
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-MessageType: newchange

Gopher Robot (Gerrit)

unread,
Jul 9, 2022, 1:09:33 PM7/9/22
to Gerrit Bot, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gopher Robot abandoned this change.

View Change

Abandoned GitHub PR golang/example#18 has been closed.

To view, visit change 303889. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: example
Gerrit-Branch: master
Gerrit-Change-Id: Ibb322c3fd85fde3d586f700cb4d6ec4acf5106f9
Gerrit-Change-Number: 303889
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-MessageType: abandon
Reply all
Reply to author
Forward
0 new messages