mirror of
https://github.com/golang/go
synced 2024-11-18 13:34:41 -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>
23 lines
516 B
Go
23 lines
516 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"
|
|
"strings"
|
|
)
|
|
|
|
// ToURL returns the file uri for a proxy directory.
|
|
func ToURL(dir string) string {
|
|
// file URLs on Windows must start with file:///. See golang.org/issue/6027.
|
|
path := filepath.ToSlash(dir)
|
|
if !strings.HasPrefix(path, "/") {
|
|
path = "/" + path
|
|
}
|
|
return "file://" + path
|
|
}
|