Use full name for value field
This commit is contained in:
parent
e64a903c27
commit
9438d7bc19
8
field.go
8
field.go
@ -9,7 +9,7 @@ type field struct {
|
|||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Kind string `json:"kind"`
|
Kind string `json:"kind"`
|
||||||
Val interface{} `json:"val"`
|
Value interface{} `json:"val"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractFields(st interface{}, path string) []field {
|
func extractFields(st interface{}, path string) []field {
|
||||||
@ -47,7 +47,7 @@ func extractFields(st interface{}, path string) []field {
|
|||||||
Path: path + ftyp.Name,
|
Path: path + ftyp.Name,
|
||||||
Name: ftyp.Name,
|
Name: ftyp.Name,
|
||||||
Kind: kind.String(),
|
Kind: kind.String(),
|
||||||
Val: fval.Interface(),
|
Value: fval.Interface(),
|
||||||
})
|
})
|
||||||
default:
|
default:
|
||||||
log.Printf("Field type %q not supported for field %q\n", kind, path+ftyp.Name)
|
log.Printf("Field type %q not supported for field %q\n", kind, path+ftyp.Name)
|
||||||
@ -63,8 +63,8 @@ func diff(a, b interface{}) map[string][]interface{} {
|
|||||||
|
|
||||||
res := make(map[string][]interface{})
|
res := make(map[string][]interface{})
|
||||||
for name, f := range af {
|
for name, f := range af {
|
||||||
if bf[name].Val != f.Val {
|
if bf[name].Value != f.Value {
|
||||||
res[name] = []interface{}{f.Val, bf[name].Val}
|
res[name] = []interface{}{f.Value, bf[name].Value}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ func TestExtractFields(t *testing.T) {
|
|||||||
if f.Kind != kind {
|
if f.Kind != kind {
|
||||||
t.Errorf("%s expected to be of kind %q, got %q", fname, kind, f.Kind)
|
t.Errorf("%s expected to be of kind %q, got %q", fname, kind, f.Kind)
|
||||||
}
|
}
|
||||||
if f.Val != val {
|
if f.Value != val {
|
||||||
t.Errorf("%s expected to have value %q, got %q", fname, val, f.Val)
|
t.Errorf("%s expected to have value %q, got %q", fname, val, f.Value)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
t.Errorf("Missing %s field", fname)
|
t.Errorf("Missing %s field", fname)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user