From e4aec1fa8a9c57672b783d16dd122cb4e6708089 Mon Sep 17 00:00:00 2001 From: Jes Cok Date: Tue, 1 Aug 2023 13:28:14 +0000 Subject: [PATCH] text/template: use "IsValid" instead of "!= zero" to compare zero Value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See CL 308769 Change-Id: I0caa0a84215b3d4b8b3dc6f041b6cd9cbe2c0908 GitHub-Last-Rev: e3aa5bde23fe26cbb6711a6ffbf4856a23fa6f54 GitHub-Pull-Request: golang/go#61657 Reviewed-on: https://go-review.googlesource.com/c/go/+/514195 Run-TryBot: Ian Lance Taylor Auto-Submit: Ian Lance Taylor Reviewed-by: David Chase TryBot-Result: Gopher Robot Reviewed-by: Daniel Martí Reviewed-by: Rob Pike Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor --- src/text/template/funcs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/text/template/funcs.go b/src/text/template/funcs.go index b5a8c9ec50..a949f896fa 100644 --- a/src/text/template/funcs.go +++ b/src/text/template/funcs.go @@ -478,7 +478,7 @@ func eq(arg1 reflect.Value, arg2 ...reflect.Value) (bool, error) { case k1 == uintKind && k2 == intKind: truth = arg.Int() >= 0 && arg1.Uint() == uint64(arg.Int()) default: - if arg1 != zero && arg != zero { + if arg1.IsValid() && arg.IsValid() { return false, errBadComparison } }