diff --git a/github.go b/github.go index 74f2eac..85c2775 100644 --- a/github.go +++ b/github.go @@ -4,6 +4,7 @@ import ( "context" "errors" "net/http" + "time" "github.com/shurcooL/githubv4" "golang.org/x/oauth2" @@ -61,6 +62,7 @@ func NewGithubClient( token string, releaseFilter ReleaseFilter, assetFilter AssetFilter, + connectionTimeout time.Duration, ) *GithubLocator { var httpClient *http.Client if token != "" { @@ -68,6 +70,11 @@ func NewGithubClient( &oauth2.Token{AccessToken: token}, ) httpClient = oauth2.NewClient(context.Background(), src) + httpClient.Timeout = connectionTimeout + } + + if httpClient == nil { + httpClient = &http.Client{Timeout: connectionTimeout} } client := githubv4.NewClient(httpClient)