1 // Nearly all code is taken from src/cmd/go/internal/auth/netrc.go
13 func findInNetrc(host string) (string, string) {
14 netrcPath, ok := os.LookupEnv("NETRC")
16 homeDir, err := os.UserHomeDir()
20 netrcPath = filepath.Join(homeDir, ".netrc")
22 data, err := ioutil.ReadFile(netrcPath)
24 if os.IsNotExist(err) {
30 var machine, login, password string
31 for _, line := range strings.Split(string(data), "\n") {
38 fields := strings.Fields(line)
40 for ; i < len(fields)-1; i += 2 {
51 password = fields[i+1]
55 if machine != "" && login != "" && password != "" {
57 return login, password
59 machine, login, password = "", "", ""
62 if i < len(fields) && fields[i] == "default" {