1
0
mirror of https://github.com/golang/go synced 2024-11-17 17:54:48 -07:00

text/template: use "IsValid" instead of "!= zero" to compare zero Value

See CL 308769

Change-Id: I0caa0a84215b3d4b8b3dc6f041b6cd9cbe2c0908
GitHub-Last-Rev: e3aa5bde23
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>
This commit is contained in:
Jes Cok 2023-08-01 13:28:14 +00:00 committed by Gopher Robot
parent 3687f77069
commit e4aec1fa8a

View File

@ -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
}
}