mirror of
https://github.com/golang/go
synced 2024-11-05 16:46:10 -07:00
07bb9fb2f9
Both packagestest and the gopls regtests need to write module data to the filesystem in proxy structure. Since this seems like a common and self-contained concerned, factor this out into a shared package. Change-Id: I5275dbc0cd7b13290061e8bb559d6dd287fbb275 Reviewed-on: https://go-review.googlesource.com/c/tools/+/227841 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
19 lines
647 B
Go
19 lines
647 B
Go
// +build !go1.13
|
|
|
|
// Copyright 2020 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package proxydir
|
|
|
|
import "path/filepath"
|
|
|
|
// ToURL returns the file uri for a proxy directory.
|
|
func ToURL(dir string) string {
|
|
// Prior to go1.13, the Go command on Windows only accepted GOPROXY file URLs
|
|
// of the form file://C:/path/to/proxy. This was incorrect: when parsed, "C:"
|
|
// is interpreted as the host. See golang.org/issue/6027. This has been
|
|
// fixed in go1.13, but we emit the old format for old releases.
|
|
return "file://" + filepath.ToSlash(dir)
|
|
}
|