Remove the leading slash from GOPROXY file:// URLs.
Updates #31675
Change-Id: Id45af2a806afc3c216181c13f6bc73713b925693
Reviewed-on: https://go-review.googlesource.com/c/go/+/173499
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
"os"
pathpkg "path"
"path/filepath"
+ "runtime"
"strings"
"sync"
"time"
+ "unicode"
"cmd/go/internal/base"
"cmd/go/internal/cfg"
if err != nil {
return nil, err
}
+ if runtime.GOOS == "windows" && len(rawPath) >= 4 && rawPath[0] == '/' && unicode.IsLetter(rune(rawPath[1])) && rawPath[2] == ':' {
+ // On Windows, file URLs look like "file:///C:/foo/bar". url.Path will
+ // start with a slash which must be removed. See golang.org/issue/6027.
+ rawPath = rawPath[1:]
+ }
return os.Open(filepath.FromSlash(rawPath))
}