func buildUserObject(r io.Reader, u goth.User) (goth.User, error) {
	// Response object from Steam
	apiResponse := struct {
		Response struct {
			Players []struct {
				UserID              string `json:"steamid"`
				NickName            string `json:"personaname"`
				Name                string `json:"realname"`
				AvatarURL           string `json:"avatarfull"`
				LocationCountryCode string `json:"loccountrycode"`
				LocationStateCode   string `json:"locstatecode"`
			} `json:"players"`
		} `json:"response"`
	}{}

	err := json.NewDecoder(r).Decode(&apiResponse)
	if err != nil {
		return u, err
	}

	if l := len(apiResponse.Response.Players); l != 1 {
		return u, fmt.Errorf("Expected one player in API response. Got %d.", l)
	}

	player := apiResponse.Response.Players[0]
	u.UserID = player.UserID
	u.Name = player.Name
	if len(player.Name) == 0 {
		u.Name = "No name is provided by the Steam API"
	}
	u.NickName = player.NickName
	u.AvatarURL = player.AvatarURL
	u.Email = "No email is provided by the Steam API"
	u.Description = "No description is provided by the Steam API"

	if len(player.LocationStateCode) > 0 && len(player.LocationCountryCode) > 0 {
		u.Location = fmt.Sprintf("%s, %s", player.LocationStateCode, player.LocationCountryCode)
	} else if len(player.LocationCountryCode) > 0 {
		u.Location = player.LocationCountryCode
	} else if len(player.LocationStateCode) > 0 {
		u.Location = player.LocationStateCode
	} else {
		u.Location = "No location is provided by the Steam API"
	}

	return u, nil
}
// buildUserObject is an internal function to build a goth.User object
// based in the data stored in r
buildUserObject is an internal function to build a goth.User object
based in the data stored in r
// buildUserObject is an internal function to build a goth . User object // based in the data stored in r
func buildUserObject(r io.Reader, u goth.User) (goth.User, error) {
	apiResponse := struct {
		Response struct {
			Players []struct {
				UserID              string `json:"steamid"`
				NickName            string `json:"personaname"`
				Name                string `json:"realname"`
				AvatarURL           string `json:"avatarfull"`
				LocationCountryCode string `json:"loccountrycode"`
				LocationStateCode   string `json:"locstatecode"`
			} `json:"players"`
		} `json:"response"`
	}{}
	err := json.NewDecoder(r).Decode(&apiResponse)
	if err != nil {
		return u, err
	}
	if l := len(apiResponse.Response.Players); l != 1 {
		return u, fmt.Errorf("Expected one player in API response. Got %d.", l)
	}
	player := apiResponse.Response.Players[0]
	u.UserID = player.UserID
	u.Name = player.Name
	if len(player.Name) == 0 {
		u.Name = "No name is provided by the Steam API"
	}
	u.NickName = player.NickName
	u.AvatarURL = player.AvatarURL
	u.Email = "No email is provided by the Steam API"
	u.Description = "No description is provided by the Steam API"
	if len(player.LocationStateCode) > 0 && len(player.LocationCountryCode) > 0 {
		u.Location = fmt.Sprintf("%s, %s", player.LocationStateCode, player.LocationCountryCode)
	} else if len(player.LocationCountryCode) > 0 {
		u.Location = player.LocationCountryCode
	} else if len(player.LocationStateCode) > 0 {
		u.Location = player.LocationStateCode
	} else {
		u.Location = "No location is provided by the Steam API"
	}
	return u, nil
}
func buildUserObject ( r io . Reader , u goth . User ) ( goth . User , error ) { apiResponse := struct { Response struct { Players [ ] struct { UserID string `json:"steamid"` NickName string `json:"personaname"` Name string `json:"realname"` AvatarURL string `json:"avatarfull"` LocationCountryCode string `json:"loccountrycode"` LocationStateCode string `json:"locstatecode"` } `json:"players"` } `json:"response"` } { } err := json . NewDecoder ( r ) . Decode ( & apiResponse ) if err != nil { return u , err } if l := len ( apiResponse . Response . Players ) ; l != 1 { return u , fmt . Errorf ( " " , l ) } player := apiResponse . Response . Players [ 0 ] u . UserID = player . UserID u . Name = player . Name if len ( player . Name ) == 0 { u . Name = " " } u . NickName = player . NickName u . AvatarURL = player . AvatarURL u . Email = " " u . Description = " " if len ( player . LocationStateCode ) > 0 && len ( player . LocationCountryCode ) > 0 { u . Location = fmt . Sprintf ( " " , player . LocationStateCode , player . LocationCountryCode ) } else if len ( player . LocationCountryCode ) > 0 { u . Location = player . LocationCountryCode } else if len ( player . LocationStateCode ) > 0 { u . Location = player . LocationStateCode } else { u . Location = " " } return u , nil }
buildUserObject is an internal function to build a goth.User object
based in the data stored in r
buildUserObject is an internal function to build a goth . User object based in the data stored in r
// Response object from Steam