google / google/go-cmp

take address of field for comparison

Open
#310 4 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
4.7k
Forks
243
PR merge metrics
No merged PRs in 30d

Description

I'm using [intsets.Sparse](https://pkg.go.dev/golang.org/x/tools/container/intsets#Sparse) as a field in a struct:

```go
type T struct {
v intsets.Sparse
// other fields
}
```

When traversing `T`, the field `v` is copied, causing [all methods to fail](https://cs.opensource.google/go/x/tools/+/refs/tags/v0.2.0:container/intsets/sparse.go;l=264). This precludes the use of `Transformer`.

Ideally, there would be an `Option` that would take the address of the field for use with other `Option`s. Notably, `Sparse` has an `Equals(*Sparse) bool` method, so perhaps an alternate idea is to allow different equality methods? But I'm not sure whether `go-cmp` will take the address of a field in order to invoke the `Equal` method.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.