-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: use go-github getter methods #9
refactor: use go-github getter methods #9
Conversation
Instead of getting value from pointer field directly, we should get value via go-github getter method.
@@ -173,12 +173,12 @@ func getPRInfos(prs []*github.PullRequest) []PR { | |||
prInfos := make([]PR, len(prs)) | |||
|
|||
for i, pr := range prs { | |||
repos := strings.Split(*pr.URL, "/") | |||
repos := strings.Split(pr.GetURL(), "/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Labels: pr.Labels, | ||
User: pr.User.Login, | ||
User: pr.User.GetLogin(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
prInfos[i] = PR{ | ||
Number: pr.Number, | ||
Number: pr.GetNumber(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I learned that there are functions to get each field in the library 😄
Instead of getting value from pointer field directly,
we should get value via go-github getter method.
By getter method, we can prevent panic due to
nil
.ex. PullRequest.GetURL: https://pkg.go.dev/github.com/google/go-github/github#PullRequest.GetURL