Skip to content

Commit 80e2e47

Browse files
quantonganhgopherbot
authored andcommitted
[release-branch.go1.24] cmd/go: initialize req.Header when loading git credential
Fixes golang#71687 Change-Id: I3d733a50b4451dfb571aba91a28387ba9e0614dc Reviewed-on: https://go-review.googlesource.com/c/go/+/647615 Reviewed-by: Michael Matloob <[email protected]> Reviewed-by: Sam Thanawalla <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> (cherry picked from commit 58834c3) Reviewed-on: https://go-review.googlesource.com/c/go/+/648936 Reviewed-by: Dmitri Shuralyov <[email protected]> TryBot-Bypass: Dmitri Shuralyov <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]>
1 parent 3901409 commit 80e2e47

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/cmd/go/internal/auth/auth.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ func runGoAuth(client *http.Client, res *http.Response, url string) {
128128
// If no GOAUTH command provided a credential for the given url
129129
// and an error occurred, log the error.
130130
if cfg.BuildX && url != "" {
131-
if ok := loadCredential(&http.Request{}, url); !ok && len(cmdErrs) > 0 {
131+
req := &http.Request{Header: make(http.Header)}
132+
if ok := loadCredential(req, url); !ok && len(cmdErrs) > 0 {
132133
log.Printf("GOAUTH encountered errors for %s:", url)
133134
for _, err := range cmdErrs {
134135
log.Printf(" %v", err)

src/cmd/go/testdata/script/goauth_git.txt

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ go get vcs-test.golang.org/auth/or401
4949
go mod tidy
5050
go list all
5151
stdout vcs-test.golang.org/auth/or404
52+
# With cached credentials, re-downloading in debug mode should succeed.
53+
go get -x vcs-test.golang.org/auth/or401
5254

5355
# Clearing GOAUTH credentials should result in failures.
5456
env GOAUTH='off'

0 commit comments

Comments
 (0)