Index: service/datastore/key.go |
diff --git a/service/datastore/key.go b/service/datastore/key.go |
index b2b9e45f37da085b33f76f68f0f7d9ea5b791dc5..227858858bc76da9850d0ecb019ca1ed6eac8320 100644 |
--- a/service/datastore/key.go |
+++ b/service/datastore/key.go |
@@ -320,6 +320,21 @@ func (k *Key) UnmarshalJSON(buf []byte) error { |
return nil |
} |
+// GobEncode allows the Key to be encoded in a Gob struct. |
+func (k *Key) GobEncode() ([]byte, error) { |
+ return []byte(k.Encode()), nil |
+} |
+ |
+// GobDecode allows the Key to be decoded in a Gob struct. |
+func (k *Key) GobDecode(buf []byte) error { |
+ nk, err := NewKeyEncoded(string(buf)) |
+ if err != nil { |
+ return err |
+ } |
+ *k = *nk |
+ return nil |
+} |
+ |
// Root returns the entity root for the given key. |
func (k *Key) Root() *Key { |
if len(k.toks) > 1 { |