1
0
mirror of https://github.com/golang/go synced 2024-11-05 17:06:13 -07:00
go/internal/proxydir/proxydir_112.go
Rob Findley 07bb9fb2f9 internal/proxydir: add an internal package for file-based proxies
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>
2020-04-13 22:35:07 +00:00

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)
}