Index: service/datastore/pls.go |
diff --git a/service/datastore/pls.go b/service/datastore/pls.go |
index 35eb42dc3c03a94be6313915ea5ed85f40b631b7..6b9b7766b138ad126281b0e729b9065de66ec14b 100644 |
--- a/service/datastore/pls.go |
+++ b/service/datastore/pls.go |
@@ -24,11 +24,11 @@ import ( |
// |
// GetPLS supports the following struct tag syntax: |
// `gae:"fieldName[,noindex]"` -- an alternate fieldname for an exportable |
-// field. When the struct is serialized or deserialized, fieldName will be |
+// field. When the struct is serialized or deserialized, fieldName will be |
// associated with the struct field instead of the field's Go name. This is |
// useful when writing Go code which interfaces with appengine code written |
// in other languages (like python) which use lowercase as their default |
-// datastore field names. |
+// datastore field names. |
// |
// A fieldName of "-" means that gae will ignore the field for all |
// serialization/deserialization. |
@@ -87,16 +87,23 @@ import ( |
// Lines []string |
// } |
func GetPLS(obj interface{}) PropertyLoadSaver { |
+ v, err := getPLSValue(obj) |
+ if err != nil { |
+ return &structPLS{c: &structCodec{problem: err}} |
+ } |
+ c := getCodec(v.Type()) |
+ return &structPLS{v, c} |
+} |
+ |
+func getPLSValue(obj interface{}) (reflect.Value, error) { |
v := reflect.ValueOf(obj) |
if v.Kind() != reflect.Ptr || v.Elem().Kind() != reflect.Struct { |
- return &structPLS{c: &structCodec{problem: ErrInvalidEntityType}} |
+ return reflect.Value{}, ErrInvalidEntityType |
} |
if v.IsNil() { |
- return &structPLS{c: &structCodec{problem: ErrInvalidEntityType}} |
+ return reflect.Value{}, ErrInvalidEntityType |
} |
- v = v.Elem() |
- c := getCodec(v.Type()) |
- return &structPLS{v, c} |
+ return v.Elem(), nil |
} |
func getCodec(structType reflect.Type) *structCodec { |