func encode(kind, appID, namespace, stringID, intIDStr, parentKeyString string) (*datastore.Key, error) { var parent *datastore.Key = nil if parentKeyString != "" { var err error parent, err = datastore.DecodeKey(parentKeyString) if err != nil { return nil, err } } return datastorekey.CreateKey(nil, appID, namespace, kind, stringID, intID64(intIDStr), parent) }
func translate(sourceKey *datastore.Key, translateAppId bool, targetAppId string, translateNamespace bool, targetNamespace string) (*datastore.Key, error) { if !translateAppId { targetAppId = sourceKey.AppID() } if !translateNamespace { targetNamespace = sourceKey.Namespace() } var translatedParent *datastore.Key = nil if sourceKey.Parent() != nil { var err error translatedParent, err = translate(sourceKey.Parent(), translateAppId, targetAppId, translateNamespace, targetNamespace) if err != nil { return nil, err } } return datastorekey.CreateKey(nil, targetAppId, targetNamespace, sourceKey.Kind(), sourceKey.StringID(), sourceKey.IntID(), translatedParent) }