本文整理汇总了Golang中github.com/markbates/goth.User.FirstName方法的典型用法代码示例。如果您正苦于以下问题:Golang User.FirstName方法的具体用法?Golang User.FirstName怎么用?Golang User.FirstName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/markbates/goth.User
的用法示例。
在下文中一共展示了User.FirstName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: userFromReader
func userFromReader(reader io.Reader, user *goth.User) error {
u := struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
FirstName string `json:"given_name"`
LastName string `json:"family_name"`
Link string `json:"link"`
Picture string `json:"picture"`
}{}
err := json.NewDecoder(reader).Decode(&u)
if err != nil {
return err
}
user.Name = u.Name
user.FirstName = u.FirstName
user.LastName = u.LastName
user.NickName = u.Name
user.Email = u.Email
//user.Description = u.Bio
user.AvatarURL = u.Picture
user.UserID = u.ID
//user.Location = u.Location.Name
return err
}
示例2: userFromReader
// [Private] userFromReader will decode the json user and set the
// *goth.User attributes
func userFromReader(reader io.Reader, user *goth.User) error {
u := struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"fullname"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
NickName string `json:"username"`
Description string `json:"description"`
AvatarURL string `json:"avatar_720_url"`
Location string `json:"city"`
}{}
err := json.NewDecoder(reader).Decode(&u)
if err != nil {
return err
}
user.UserID = u.ID
user.Email = u.Email
user.Name = u.Name
user.FirstName = u.FirstName
user.LastName = u.LastName
user.NickName = u.NickName
user.Description = u.Description
user.AvatarURL = u.AvatarURL
user.Location = u.Location
return nil
}
示例3: userFromReader
func userFromReader(reader io.Reader, user *goth.User) error {
u := struct {
ID string `json:"id"`
Email string `json:"email"`
Bio string `json:"bio"`
Name string `json:"name"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Link string `json:"link"`
Picture struct {
Data struct {
URL string `json:"url"`
} `json:"data"`
} `json:"picture"`
Location struct {
Name string `json:"name"`
} `json:"location"`
}{}
err := json.NewDecoder(reader).Decode(&u)
if err != nil {
return err
}
user.Name = u.Name
user.FirstName = u.FirstName
user.LastName = u.LastName
user.NickName = u.Name
user.Email = u.Email
user.Description = u.Bio
user.AvatarURL = u.Picture.Data.URL
user.UserID = u.ID
user.Location = u.Location.Name
return err
}