Skip to content

Commit

Permalink
bson: Fix for ,inline-d structs of unexported embedded for Go 1.6.
Browse files Browse the repository at this point in the history
Simply apply the recommendations described in the release document:
https://golang.org/doc/go1.6#reflect

To modify this check `f.PkgPath != ""` to this check `f.PkgPath != "" && !f.Anonymous`.
  • Loading branch information
Livio Soares committed Feb 23, 2016
1 parent 6da6d2b commit f3462d3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bson/bson.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ func getStructInfo(st reflect.Type) (*structInfo, error) {
inlineMap := -1
for i := 0; i != n; i++ {
field := st.Field(i)
if field.PkgPath != "" {
if field.PkgPath != "" && !field.Anonymous {
continue // Private field
}

Expand Down
2 changes: 1 addition & 1 deletion bson/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func isZero(v reflect.Value) bool {
return v.Interface().(time.Time).IsZero()
}
for i := 0; i < v.NumField(); i++ {
if vt.Field(i).PkgPath != "" {
if vt.Field(i).PkgPath != "" && !vt.Field(i).Anonymous {
continue // Private field
}
if !isZero(v.Field(i)) {
Expand Down

0 comments on commit f3462d3

Please sign in to comment.