-
Notifications
You must be signed in to change notification settings - Fork 892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GODRIVER-2722 Remove/unexport unnecessary interfaces. #1669
Changes from 1 commit
985f9fc
47dbd19
c3709b4
39f33cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,9 @@ | |
|
||
package bson | ||
|
||
// Proxy is an interface implemented by types that cannot themselves be directly encoded. Types | ||
// proxy is an interface implemented by types that cannot themselves be directly encoded. Types | ||
// that implement this interface with have ProxyBSON called during the encoding process and that | ||
// value will be encoded in place for the implementer. | ||
type Proxy interface { | ||
type proxy interface { | ||
ProxyBSON() (interface{}, error) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should consider completely removing the |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -181,7 +181,9 @@ func (sc *StructCodec) EncodeValue(ec EncodeContext, vw ValueWriter, val reflect | |
encoder := desc.encoder | ||
|
||
var empty bool | ||
if cz, ok := encoder.(CodecZeroer); ok { | ||
if cz, ok := encoder.(interface { | ||
IsTypeZero(interface{}) bool | ||
}); ok { | ||
empty = cz.IsTypeZero(rv.Interface()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should consider completely removing the |
||
} else if rv.Kind() == reflect.Interface { | ||
// isEmpty will not treat an interface rv as an interface, so we need to check for the | ||
|
@@ -398,7 +400,7 @@ func (sc *StructCodec) DecodeValue(dc DecodeContext, vr ValueReader, val reflect | |
func isEmpty(v reflect.Value, omitZeroStruct bool) bool { | ||
kind := v.Kind() | ||
if (kind != reflect.Ptr || !v.IsNil()) && v.Type().Implements(tZeroer) { | ||
return v.Interface().(Zeroer).IsZero() | ||
return v.Interface().(zeroer).IsZero() | ||
} | ||
switch kind { | ||
case reflect.Array, reflect.Map, reflect.Slice, reflect.String: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering the recent relevance of
IsZero
, it's possible we may need to keep theZeroer
interface exported.