mirror of
https://github.com/golang/go
synced 2024-11-05 17:36:15 -07:00
c700c23cef
The upcoming built-in zero value provides an idiomatic way to test for zero by comparing to the zero literal: v == zero. The reflect package is meant to provide a programmatic way to perform operations that the Go language itself provides. Thus, it seems prudent that reflect.ValueOf(&v).Elem().IsZero() is identical to v == zero. This change alters the behavior of Value.IsZero in two concrete ways: * negative zero is identical to zero * blank fields in a struct are ignored Prior to this change, we were already in an inconsistent state due to a regression introduced by CL 411478. The new behavior was already the case for comparable composite types. This change makes it consistent for all other types (in particular incomparable composite types and standalone numbers). Updates #61372 Fixes #61827 Change-Id: Id23fb97eb3b8921417cc75a1d3ead963e22dc3d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/517777 Reviewed-by: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> |
||
---|---|---|
.. | ||
asm.html | ||
go1.17_spec.html | ||
go1.22.html | ||
go_mem.html | ||
go_spec.html | ||
godebug.md |