From 64c2072a94281fe5b19f9349b522881751347726 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 31 Jul 2023 15:24:18 -0700 Subject: [PATCH] text/template, html/template: use reflect.TypeFor for known types MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit For #60088 Change-Id: Ibc3983ca5cfe396087ddfa96c43cfe32ca47129a Reviewed-on: https://go-review.googlesource.com/c/go/+/514640 Auto-Submit: Ian Lance Taylor Reviewed-by: Daniel Martí Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: David Chase Reviewed-by: Rob Pike Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor --- src/html/template/content.go | 4 ++-- src/html/template/exec_test.go | 4 ++-- src/html/template/js.go | 2 +- src/text/template/exec.go | 8 ++++---- src/text/template/exec_test.go | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/html/template/content.go b/src/html/template/content.go index 49d2f261af..6a9eb4e3cb 100644 --- a/src/html/template/content.go +++ b/src/html/template/content.go @@ -128,8 +128,8 @@ func indirect(a any) any { } var ( - errorType = reflect.TypeOf((*error)(nil)).Elem() - fmtStringerType = reflect.TypeOf((*fmt.Stringer)(nil)).Elem() + errorType = reflect.TypeFor[error]() + fmtStringerType = reflect.TypeFor[fmt.Stringer]() ) // indirectToStringerOrError returns the value, after dereferencing as many times diff --git a/src/html/template/exec_test.go b/src/html/template/exec_test.go index 51923ff9c7..05302156e0 100644 --- a/src/html/template/exec_test.go +++ b/src/html/template/exec_test.go @@ -268,8 +268,8 @@ type execTest struct { // of the max int boundary. // We do it this way so the test doesn't depend on ints being 32 bits. var ( - bigInt = fmt.Sprintf("0x%x", int(1<