Add APIObject for generic inclusion of API objects.

Includes test and json/yaml getters and setters.
This commit is contained in:
Daniel Smith
2014-07-18 18:51:28 -07:00
parent d1de579070
commit 69c483f620
7 changed files with 189 additions and 35 deletions

View File

@@ -66,7 +66,7 @@ func FindJSONBaseRO(obj interface{}) (JSONBase, error) {
v = v.Elem()
}
if v.Kind() != reflect.Struct {
return JSONBase{}, fmt.Errorf("expected struct, but got %v", v.Type().Name())
return JSONBase{}, fmt.Errorf("expected struct, but got %v (%#v)", v.Type().Name(), v.Interface())
}
jsonBase := v.FieldByName("JSONBase")
if !jsonBase.IsValid() {
@@ -125,7 +125,7 @@ func nameAndJSONBase(obj interface{}) (string, *JSONBase, error) {
v = v.Elem()
name := v.Type().Name()
if v.Kind() != reflect.Struct {
return "", nil, fmt.Errorf("expected struct, but got %v", name)
return "", nil, fmt.Errorf("expected struct, but got %v: %v (%#v)", v.Kind(), v.Type().Name(), v.Interface())
}
jsonBase := v.FieldByName("JSONBase")
if !jsonBase.IsValid() {