diff options
author | Joe Tsai <joetsai@digital-static.net> | 2019-02-25 17:42:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-25 17:42:07 -0800 |
commit | 7d316222e18768fec502f76523cd295a12f7f09a (patch) | |
tree | e7568ffbb518d8425005577c717c7339bcda14d2 /cmp/compare.go | |
parent | a02fa9f0a2b3432ef9a311f083acef9aa9bb123b (diff) | |
download | go-cmp-7d316222e18768fec502f76523cd295a12f7f09a.tar.gz |
Rename unsafe_x.go as export_x.go (#117)
Rename the file based on what it does rather than how its implemented.
Diffstat (limited to 'cmp/compare.go')
-rw-r--r-- | cmp/compare.go | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/cmp/compare.go b/cmp/compare.go index 654f46a..7681d4a 100644 --- a/cmp/compare.go +++ b/cmp/compare.go @@ -298,10 +298,9 @@ func (s *state) compareAny(vx, vy reflect.Value) { func (s *state) tryExporting(vx, vy reflect.Value) (reflect.Value, reflect.Value) { if sf, ok := s.curPath[len(s.curPath)-1].(*structField); ok && sf.unexported { if sf.force { - // Use unsafe pointer arithmetic to get read-write access to an - // unexported field in the struct. - vx = unsafeRetrieveField(sf.pvx, sf.field) - vy = unsafeRetrieveField(sf.pvy, sf.field) + // Forcibly obtain read-write access to an unexported struct field. + vx = retrieveUnexportedField(sf.pvx, sf.field) + vy = retrieveUnexportedField(sf.pvy, sf.field) } else { // We are not allowed to export the value, so invalidate them // so that tryOptions can panic later if not explicitly ignored. @@ -423,7 +422,7 @@ func (s *state) compareStruct(vx, vy reflect.Value, t reflect.Type) { // Defer checking of unexported fields until later to give an // Ignore a chance to ignore the field. if !vax.IsValid() || !vay.IsValid() { - // For unsafeRetrieveField to work, the parent struct must + // For retrieveUnexportedField to work, the parent struct must // be addressable. Create a new copy of the values if // necessary to make them addressable. vax = makeAddressable(vx) |