forked from golang/tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go/packages/packagestest: fix GOPROXY file URLs for Windows
Amends prematurely submitted CL 173918. We now use file:/// URLs for go1.13 and later and file:// URLs for go1.12 and earlier. Fixes golang/go#31675 Change-Id: I009c63a900bdfd091bf46def5cea5a0843639b47 Reviewed-on: https://go-review.googlesource.com/c/tools/+/173919 Run-TryBot: Jay Conrod <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Cottrell <[email protected]>
- Loading branch information
Jay Conrod
committed
Apr 25, 2019
1 parent
e54115a
commit 2d660fb
Showing
6 changed files
with
84 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// +build !go1.13 | ||
|
||
// Copyright 2019 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 packagestest | ||
|
||
import "path/filepath" | ||
|
||
func proxyDirToURL(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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// +build go1.13 | ||
|
||
// Copyright 2018 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 packagestest | ||
|
||
import ( | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
func proxyDirToURL(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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// +build !go1.13 | ||
|
||
// Copyright 2019 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 imports | ||
|
||
import "path/filepath" | ||
|
||
// TODO: use proxy functionality in golang.org/x/tools/go/packages/packagestest | ||
// instead of copying it here. | ||
|
||
func proxyDirToURL(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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// +build go1.13 | ||
|
||
// Copyright 2018 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 imports | ||
|
||
import ( | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
// TODO: use proxy functionality in golang.org/x/tools/go/packages/packagestest | ||
// instead of copying it here. | ||
|
||
func proxyDirToURL(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 | ||
} |