diff --git a/decoder.go b/decoder.go index 3b7ab74..c15e608 100644 --- a/decoder.go +++ b/decoder.go @@ -503,7 +503,7 @@ func convertToValue(graphId int64, conf structDecoratorConfig, props map[string] continue } - mapKey := strings.Replace(k, fieldConfig.Name + ".", "", 1) + mapKey := strings.Replace(k, fieldConfig.Name+".", "", 1) mapVal.SetMapIndex(reflect.ValueOf(mapKey), reflect.ValueOf(v)) } @@ -525,7 +525,7 @@ func convertToValue(graphId int64, conf structDecoratorConfig, props map[string] rawVal := reflect.ValueOf(raw) - if raw == nil || rawVal.IsZero(){ + if raw == nil || rawVal.IsZero() { continue //its already initialized to 0 value, no need to do anything } else { if fieldConfig.IsTime { diff --git a/decoder_test.go b/decoder_test.go index c342869..6bcf77c 100644 --- a/decoder_test.go +++ b/decoder_test.go @@ -158,10 +158,10 @@ type tdString string type tdInt int type f struct { - Id int64 `gogm:"name=id"` - UUID string `gogm:"pk;name=uuid"` - Parents []*f `gogm:"direction=outgoing;relationship=test"` - Children []*f `gogm:"direction=incoming;relationship=test"` + Id int64 `gogm:"name=id"` + UUID string `gogm:"pk;name=uuid"` + Parents []*f `gogm:"direction=outgoing;relationship=test"` + Children []*f `gogm:"direction=incoming;relationship=test"` } type a struct { @@ -253,21 +253,21 @@ func TestDecoder(t *testing.T) { graph.Node{ Labels: []string{"f"}, Properties: map[string]interface{}{ - "uuid": "0", + "uuid": "0", }, NodeIdentity: 0, }, graph.Node{ Labels: []string{"f"}, Properties: map[string]interface{}{ - "uuid": "1", + "uuid": "1", }, NodeIdentity: 1, }, graph.Node{ Labels: []string{"f"}, Properties: map[string]interface{}{ - "uuid": "2", + "uuid": "2", }, NodeIdentity: 2, }, @@ -282,24 +282,24 @@ func TestDecoder(t *testing.T) { Type: "test", }, }, - Sequence: []int{1, 1, /*#*/ 2, 2}, + Sequence: []int{1, 1 /*#*/, 2, 2}, }, }, } f0 := f{ - Id: 0, - UUID: "0", + Id: 0, + UUID: "0", } f1 := f{ - Id: 1, - UUID: "1", + Id: 1, + UUID: "1", } f2 := f{ - Id: 2, - UUID: "2", + Id: 2, + UUID: "2", } f0.Parents = []*f{&f1} @@ -622,10 +622,10 @@ func TestDecoder(t *testing.T) { NodeIdentity: 1, Labels: []string{"propsTest"}, Properties: map[string]interface{}{ - "uuid": var5uuid, - "props.test.test": "test", - "props.test2": "test2", - "props.test3": "test3", + "uuid": var5uuid, + "props.test.test": "test", + "props.test2": "test2", + "props.test3": "test3", }, }, }, @@ -641,9 +641,9 @@ func TestDecoder(t *testing.T) { Id: 1, UUID: var5uuid, Props: map[string]interface{}{ - "test.test": "test", - "test2": "test2", - "test3": "test3", + "test.test": "test", + "test2": "test2", + "test3": "test3", }, } @@ -757,5 +757,4 @@ func TestDecoder(t *testing.T) { req.Equal(int64(55), readin9.Id) req.Equal("dasdfas", readin9.UUID) - }