-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add default GitHub API client #501
Add default GitHub API client #501
Conversation
e63d1a1
to
519cd2b
Compare
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.
Just one minor nit
source/github/github.go
Outdated
return nil, ErrNoUserInfo | ||
} | ||
// use http.DefaultClient | ||
client = nil |
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.
Doesn't client
default to nil
? Invert the condition and don't bother with an else
branch.
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.
Done.
g := &Github{} | ||
owner := "golang-migrate" | ||
repo := "migrate" | ||
path := "source/github/examples/migrations" |
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.
Nice! Thanks for adding tests!
cd9553a
to
6ca622c
Compare
source/github/github.go
Outdated
return nil, ErrNoUserInfo | ||
} | ||
// client defaults to http.DefaultClient | ||
client = nil |
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.
Replace this with var client *http.Client
. You don't need to set the pointer to nil
since it'll default to nil.
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.
Nice catch. Do you think // client defaults to http.DefaultClient
comment is needed above var client *http.Client
?
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.
Yeah, let's leave that comment
…e into github-default-client
6ca622c
to
b42a8a6
Compare
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 for the PR and for addressing all of my feedback!
@dhui hey 👋 is possible to release new version containing this change? thanks |
I want to access the migration source from GitHub without providing personal access token.
Is it possible to add such a feature since
go-github
package allows unauthenticated clients to call the API?