From: Ian Lance Taylor Date: Mon, 31 Jul 2023 22:24:18 +0000 (-0700) Subject: text/template, html/template: use reflect.TypeFor for known types X-Git-Tag: go1.22rc1~1458 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=64c2072a94281fe5b19f9349b522881751347726;p=gostls13.git text/template, html/template: use reflect.TypeFor for known types 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 --- 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<