I have the following two structs:
type Profile struct {
Email string `json:"email"`
Username string `json:"username"`
Name string `json:"name"`
Permissions []string `json:"permissions"`
}
type Session struct {
Token string `json:"token"`
User Profile `json:"user"`
}
and I'm trying to create a new Session
using:
session := Session{token, profile}
where token
is a string and profile is a Profile
both created earlier.
I'm getting the error cannot use profile (type *Profile) as type Profile in field value when I compile.
Am I missing something?
Your profile
is a pointer. Either redefine your Session
to be
type Session struct {
Token string `json:"token"`
User *Profile `json:"user"`
}
or dereference it.
session := Session{token, *profile}