提交 f6bc4d73 编写于 作者: M Mislav Marohnić

Avoid using `user.Current()` during OAuth process

Detect current username without resorting to cgo
上级 9048d4fb
......@@ -5,7 +5,7 @@ import (
"io"
"net/url"
"os"
"os/user"
"os/exec"
"strings"
"github.com/octokit/go-octokit/octokit"
......@@ -697,12 +697,21 @@ func warnExistenceOfRepo(project *Project, ee error) (err error) {
}
func authTokenNote(num int) (string, error) {
u, err := user.Current()
if err != nil {
return "", err
n := os.Getenv("USER")
if n == "" {
n = os.Getenv("USERNAME")
}
if n == "" {
whoami := exec.Command("whoami")
whoamiOut, err := whoami.Output()
if err != nil {
return "", err
}
n = strings.TrimSpace(string(whoamiOut))
}
n := u.Username
h, err := os.Hostname()
if err != nil {
return "", err
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册