Skip to content

Commit

Permalink
fix: issue where accounts without a display would crash the program d…
Browse files Browse the repository at this point in the history
…ue a nil pointer
  • Loading branch information
upsetbit committed Oct 25, 2022
1 parent 3132969 commit 41aafc2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,18 @@ func main() {

langs, organizedRepos := organizeReposByLanguage(&starred)

// every user on GitHub MUST have a username (and therefore, a valid URL that points to it)
userLogin := *authenticatedUser.Login
userAccountUrl := *authenticatedUser.URL

// but the display is optional and we should check it
userName := ""
if authenticatedUser.Name != nil {
userName = fmt.Sprintf(" (%s)", *authenticatedUser.Name)
}

fmt.Printf("# GitHub Stars\n\n")
fmt.Printf("Starred by [@%s (%s)](%s).\n\n\n", *authenticatedUser.Login, *authenticatedUser.Name, *authenticatedUser.URL)
fmt.Printf("Starred by [@%s%s](%s).\n\n\n", userLogin, userName, userAccountUrl)

fmt.Printf("## Summary\n\n")
for _, lang := range langs {
Expand Down

0 comments on commit 41aafc2

Please sign in to comment.