aboutsummaryrefslogtreecommitdiff
path: root/cmp/export_unsafe.go
AgeCommit message (Collapse)Author
2022-01-04Add //go:build lines (#285)Tobias Klauser
Starting with Go 1.17, //go:build lines are preferred over // +build lines, see https://golang.org/doc/go1.17#build-lines and https://golang.org/design/draft-gobuild for details. This change was generated by running Go 1.17 go fmt ./... which automatically adds //go:build lines based on the existing // +build lines. Also update the corresponding GitHub action to use Go 1.17 gofmt.
2020-09-23Fix license headers (#236)Joe Tsai
There is no LICENSE.md file, but there is a LICENSE file.
2020-06-09Fix exporter to handle nil interface values (#207)Joe Tsai
A shallow copy with reflect.ValueOf(v.Interface()) does not work if v is a nil interface value. Special case the edge case by checking for a nil value and create a new one use reflect.Zero.
2020-06-08Avoid leaking implementation details of the exporter (#206)Joe Tsai
The current implementation for forcibly exporting fields relies on the reflect.Value.Addr method for the parent struct value, where it copies a non-addressable struct onto to the heap so that it is addressable. However, this action leaks a subtle detail of how the internal implementation works since the accessed field for within a struct is only addressable if and only if the parent struct is also addressable. Modify the implementation to avoid leaking this implementation detail by shallow copying the accessed unexported field to remove any notion of addressability if the parent struct is also unaddressable. Fixes #181
2019-12-16Add Exporter option (#176)Joe Tsai
Add an Exporter option that accepts a function to determine which struct types to permit access to unexported fields. Treat this as a first-class option and implement AllowUnexported in terms of the new Exporter option. The new Exporter option: * Better matches the existing style of top-level options both by name (e.g., Comparer, Transformer, and Reporter) and by API style (all accept a function). * Is more flexible as it enables users to functionally implement AllowAllUnexported by simply doing: Exporter(func(reflect.Type) bool { return true }) Fixes #40
2019-10-28Make retrieveUnexportedField pass Go 1.14's checkptr validation (#169)Brad Fitzpatrick
Fixes #167
2019-02-25Rename unsafe_x.go as export_x.go (#117)Joe Tsai
Rename the file based on what it does rather than how its implemented.