A user has a number of id fields - one for each type of social login:
type User struct {
Name string
Github_id string
Facebook_id string
Google_id string
}
I have variables that store the provider
and id
:
provider := "github" //could be facebook or google too
id := "12345"
and a user:
var user User
user.Name = "Bob"
but how can I assign the id to the correct property? I've tried:
if provider == "github" {
field := "Github_id"
user.field = id //and also user[field] = id
}
but no success so far.
Additional Note
My users may have multiple social login accounts so I can't just use a single social_id
property as a solution to this problem.