I have a custom struct which has an unexported field. I want to be able to compare values with type of this struct, but I am receiving panic message like this:
panic: cannot handle unexported field at ...
consider using a custom Comparer; if you control the implementation of type, you can also consider using an Exporter, AllowUnexported, or cmpopts.IgnoreUnexported
Sample Code:
type MyType struct {
ExpField int
unexpField string
}
t1 := MyType{ExpField: 1}
t2 := MyType{ExpField: 2}
result := cmp.Equal(t1, t2)
How to fix this error and compare variables?