The Intro
Hi there, I am doing a module on Go AppEngine and I have problems reading some models, that have nested models inside. The model is Party, and what I want is Permissions. But, when I get Party from datastore, Permissions struct field is of type string.
//And when I do fmt.Println(party.Permissions) show this:
%!(EXTRA string=jjrz�5878654076715008 *��jjrzshowOnMessages
*zcanInviteAssistants *zcanInviteOrganizers *zcanEditEvent
*zroleName * organizerzisAdmin *�z�4709220381360128
*��jjrzshowOnMessages *zcanInviteAssistants *zcanInviteOrganizers
*zcanEditEvent *zroleName *ownerzisAdmin *��
What is that string? There is a way to get the original struct?
The Models
Go
type Party struct {
Name string `datastore:"name"`
Permissions string `datastore:"permissions"`
}
type PartyPermission struct {
isAdmin bool
canInviteOrganizers bool
canInviteAssistants bool
canEditParty bool
showOnMessages bool
roleName string
}
Java
@Entity
public class Party implements Cloneable, Serializable {
@Id
private Long id;
private String name;
private Map<String, PartyPermission> permissions;
// constructor ...
// getters, setters, etc
}
public class PartyPermission implements Serializable {
private static final long serialVersionUID = 3019266092062869643L;
private boolean isAdmin;
private boolean canInviteOrganizers;
private boolean canInviteAssistants;
private boolean canEditEvent;
private boolean showsOnMessages;
private String roleName;
// constructor
// getters, setters, etc
}
What I've tried
I started with go, on monday 10, and I don't recognize what could be that string. I think that maybe that string was an interface and I could convert that string to an interface, and then to what I really wish, map[string]PartyPermission. So, reflection:
func (p *Party) GetPermissions() (map[string]PartyPermission) {
iPermissions := reflect.ValueOf(p.Permissions).Interface()
return iPermissions.(map[string]PartyPermission)
}
That compiles great, but Go said that string couldn't be converted to another thing. Something like:
interface conversion: interface is string, not map[string]packName.PartyPermission
Thanks for your time.