support tcnksm/go-gitconfig.GithubToken()

This commit is contained in:
Songmu 2018-01-18 19:33:31 +09:00
parent cee0f07401
commit 179b999395
1 changed files with 8 additions and 3 deletions

View File

@ -3,14 +3,16 @@ package selfupdate
import (
"context"
"fmt"
"github.com/blang/semver"
"github.com/google/go-github/github"
"golang.org/x/oauth2"
"net/http"
"os"
"regexp"
"runtime"
"strings"
"github.com/blang/semver"
"github.com/google/go-github/github"
gitconfig "github.com/tcnksm/go-gitconfig"
"golang.org/x/oauth2"
)
var reVersion = regexp.MustCompile(`\d+\.\d+\.\d+`)
@ -65,6 +67,9 @@ func findSuitableReleaseAndAsset(rels []*github.RepositoryRelease) (*github.Repo
// NewDetector crates a new detector instance. It initializes GitHub API client.
func NewDetector() *ReleaseDetector {
token := os.Getenv("GITHUB_TOKEN")
if token == "" {
token, _ = gitconfig.GithubToken()
}
ctx := context.Background()
var auth *http.Client