1
0
mirror of https://github.com/golang/go synced 2024-11-23 04:40:09 -07:00

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

See CL #308769
This commit is contained in:
Jes Cok 2023-07-31 00:01:37 +08:00
parent 457721cd52
commit e3aa5bde23

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