aboutsummaryrefslogtreecommitdiff
path: root/src/text
diff options
context:
space:
mode:
authorJes Cok <xigua67damn@gmail.com>2023-08-01 13:28:14 +0000
committerGopher Robot <gobot@golang.org>2023-08-03 15:59:13 +0000
commite4aec1fa8a9c57672b783d16dd122cb4e6708089 (patch)
tree4b5e0c200e72ce1d4d5611227c4d2d666e327d77 /src/text
parent3687f77069a8f40a596be7bd848985990908f0d9 (diff)
downloadgo-e4aec1fa8a9c57672b783d16dd122cb4e6708089.tar.xz
text/template: use "IsValid" instead of "!= zero" to compare zero Value
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 <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/text')
-rw-r--r--src/text/template/funcs.go2
1 files changed, 1 insertions, 1 deletions
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
}
}