cmd/go: GOAUTH command output can't have a trailing slash #71889
Labels
BugReport
Issues describing a possible bug in the Go implementation.
GoCommand
cmd/go
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Go version
go1.25
Output of
go env
in your module/workspace:What did you do?
I work on the GCP Artifact Registry team (private Go registries) and I am integrating with the GOAUTH environment variable in 1.24. I am working on a gcloud command that would output:
This is based on the sample at https://pkg.go.dev/cmd/go#hdr-GOAUTH_environment_variable
What did you see happen?
Go fails to attach the authorization when I run
go mod download
resulting in a 401 error (as I have access to the backend log, I can see in the backend that the request indeed does not have the auth header from the GOAUTH output).Full error:
What did you expect to see?
More detailed docs on what the output should be in the docs.
I did some digging and I think the problem is at this line:
go/src/cmd/go/internal/auth/auth.go
Line 149 in d7a1261
strings.Cut(currentPrefix, "/")
will remove the trailing slash in the URL when Go tries to match URLs in the credential cache by prefix. If I remove the trailing slash in the output of the GOAUTH command, i.e. to the following:It works, but this contradicts the example in the Godoc.
Looking at the code there seem to be two ways Go matches request URLs to those in the credential cache (by full match or by prefix match), but the documentation does not have clarification on this. I am also not sure how a full match would work given the request URL is different for every Go module proxy API endpoint.
The text was updated successfully, but these errors were encountered: