Skip to content

Commit

Permalink
- Fix finalizer
Browse files Browse the repository at this point in the history
  • Loading branch information
legion-zver committed May 9, 2018
1 parent 0ecdb11 commit 26ae63a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/finalizer/finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func Finalize(encTagName string, v interface{}, groups ...string) interface{} {
elemKind == reflect.Array ||
elemKind == reflect.Map {
ptr := elemValue.Interface()
if res := Finalize(encTagName, ptr, groups...); res != nil && res != ptr {
if res := Finalize(encTagName, ptr, groups...); res != nil {
val.SetMapIndex(key, reflect.ValueOf(res))
}
}
Expand Down
29 changes: 29 additions & 0 deletions components/finalizer/finalizer_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package finalizer

import (
"testing"

"fmt"

"github.com/itrabbit/just"
)

type ObjA struct {
Name string `json:"name"`
}

type ObjM struct {
Data just.H `json:"data,omitempty"`
}

func TestFinalize(t *testing.T) {
obj := ObjM{
Data: just.H{
"obj": ObjA{
Name: "test",
},
},
}
m := Finalize("json", &obj, "public", "private")
fmt.Println(m)
}

0 comments on commit 26ae63a

Please sign in to comment.