vendor/cmd/go/internal/web2: fix location of netrc

Windows will use the filename "_netrc" while all other OS's use ".netrc".

user.Current().HomeDir will be used for the directory for all OS's.

Fixes golang/go#24606

Change-Id: I8182b161c4d1e6a348a568975240131b033215b5
Reviewed-on: https://go-review.googlesource.com/103866
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/vendor/cmd/go/internal/web2/web.go b/vendor/cmd/go/internal/web2/web.go
index 2608ae3..9282eeb 100644
--- a/vendor/cmd/go/internal/web2/web.go
+++ b/vendor/cmd/go/internal/web2/web.go
@@ -15,6 +15,7 @@
 	"net/http"
 	"os"
 	"path/filepath"
+	"runtime"
 	"runtime/debug"
 	"strings"
 	"sync"
@@ -70,8 +71,18 @@
 	return false
 }
 
+func netrcPath() string {
+	switch runtime.GOOS {
+	case "windows":
+		return filepath.Join(os.Getenv("USERPROFILE"), "_netrc")
+	case "plan9":
+		filepath.Join(os.Getenv("home"), ".netrc")
+	}
+	return filepath.Join(os.Getenv("HOME"), ".netrc")
+}
+
 func readNetrc() {
-	data, err := ioutil.ReadFile(filepath.Join(os.Getenv("HOME"), ".netrc"))
+	data, err := ioutil.ReadFile(netrcPath())
 	if err != nil {
 		return
 	}
@@ -277,7 +288,7 @@
 scope, but you can add "repo" if you want to access private
 repositories too.
 
-Add the token to your $HOME/.netrc:
+Add the token to your $HOME/.netrc (%USERPROFILE%\_netrc on Windows):
 
     machine api.github.com login YOU password TOKEN