From 9384d34c58099657bb1b133beaf3ff37ada9b017 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 10 Sep 2020 18:53:26 -0400 Subject: text/template: allow newlines inside action delimiters This allows multiline constructs like: {{"hello" | printf}} Now that unclosed actions can span multiple lines, track and report the start of the action when reporting errors. Also clean up a few "unexpected " to be just "". Fixes #29770. Change-Id: I54c6c016029a8328b7902a4b6d85eab713ec3285 Reviewed-on: https://go-review.googlesource.com/c/go/+/254257 Trust: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Rob Pike --- src/html/template/exec_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/html/template/exec_test.go') diff --git a/src/html/template/exec_test.go b/src/html/template/exec_test.go index ec2bfcccab..fc76ee40e5 100644 --- a/src/html/template/exec_test.go +++ b/src/html/template/exec_test.go @@ -1302,7 +1302,7 @@ func TestUnterminatedStringError(t *testing.T) { t.Fatal("expected error") } str := err.Error() - if !strings.Contains(str, "X:3: unexpected unterminated raw quoted string") { + if !strings.Contains(str, "X:3: unterminated raw quoted string") { t.Fatalf("unexpected error: %s", str) } } -- cgit v1.2.1 From 1b09d430678d4a6f73b2443463d11f75851aba8a Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 16 Oct 2020 00:49:02 -0400 Subject: all: update references to symbols moved from io/ioutil to io The old ioutil references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. Also excluded vendored code. For #41190. Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/263142 Trust: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Emmanuel Odeke --- src/html/template/exec_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/html/template/exec_test.go') diff --git a/src/html/template/exec_test.go b/src/html/template/exec_test.go index fc76ee40e5..232945a0bb 100644 --- a/src/html/template/exec_test.go +++ b/src/html/template/exec_test.go @@ -11,7 +11,7 @@ import ( "errors" "flag" "fmt" - "io/ioutil" + "io" "reflect" "strings" "testing" @@ -1335,7 +1335,7 @@ func TestExecuteGivesExecError(t *testing.T) { if err != nil { t.Fatal(err) } - err = tmpl.Execute(ioutil.Discard, 0) + err = tmpl.Execute(io.Discard, 0) if err == nil { t.Fatal("expected error; got none") } @@ -1481,7 +1481,7 @@ func TestEvalFieldErrors(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { tmpl := Must(New("tmpl").Parse(tc.src)) - err := tmpl.Execute(ioutil.Discard, tc.value) + err := tmpl.Execute(io.Discard, tc.value) got := "" if err != nil { got = err.Error() @@ -1498,7 +1498,7 @@ func TestMaxExecDepth(t *testing.T) { t.Skip("skipping in -short mode") } tmpl := Must(New("tmpl").Parse(`{{template "tmpl" .}}`)) - err := tmpl.Execute(ioutil.Discard, nil) + err := tmpl.Execute(io.Discard, nil) got := "" if err != nil { got = err.Error() -- cgit v1.2.1