aboutsummaryrefslogtreecommitdiff
path: root/cmp
diff options
context:
space:
mode:
authorJoe Tsai <joetsai@digital-static.net>2017-07-18 13:07:28 -0700
committerGitHub <noreply@github.com>2017-07-18 13:07:28 -0700
commit1a281611eb75d66e518c28179118a82d6a9f80f2 (patch)
tree7f4154e82f7c74cf0e13e661145f8fcc986af02b /cmp
parentf299ad1c37e02b87f050c93c5d86af49a2850fc1 (diff)
downloadgo-cmp-1a281611eb75d66e518c28179118a82d6a9f80f2.tar.gz
Document cmpopts.IgnoreUnexported and AllowUnexported together (#14)
Diffstat (limited to 'cmp')
-rw-r--r--cmp/compare.go5
-rw-r--r--cmp/options.go4
2 files changed, 6 insertions, 3 deletions
diff --git a/cmp/compare.go b/cmp/compare.go
index 2f40753..ae5ad96 100644
--- a/cmp/compare.go
+++ b/cmp/compare.go
@@ -21,8 +21,9 @@
// • If no custom equality functions are used and no Equal method is defined,
// equality is determined by recursively comparing the primitive kinds on both
// values, much like reflect.DeepEqual. Unlike reflect.DeepEqual, unexported
-// fields are not compared; they result in panics unless suppressed by using
-// an Ignore option.
+// fields are not compared by default; they result in panics unless suppressed
+// by using an Ignore option (see cmpopts.IgnoreUnexported) or explictly compared
+// using the AllowUnexported option.
package cmp
import (
diff --git a/cmp/options.go b/cmp/options.go
index a01fcb5..0d05c87 100644
--- a/cmp/options.go
+++ b/cmp/options.go
@@ -251,7 +251,7 @@ type comparer struct {
// defined in an internal package where the semantic meaning of an unexported
// field is in the control of the user.
//
-// For most cases, a custom Comparer should be used instead that defines
+// For some cases, a custom Comparer should be used instead that defines
// equality as a function of the public API of a type rather than the underlying
// unexported implementation.
//
@@ -264,6 +264,8 @@ type comparer struct {
// Comparer(func(x, y reflect.Type) bool { return x == y })
// Comparer(func(x, y *regexp.Regexp) bool { return x.String() == y.String() })
//
+// In other cases, the cmpopts.IgnoreUnexported option can be used to ignore
+// all unexported fields on specified struct types.
func AllowUnexported(types ...interface{}) Option {
if !supportAllowUnexported {
panic("AllowUnexported is not supported on App Engine Classic or GopherJS")