Skip to content

Commit de4d503

Browse files
committed
cmd/go: delete GOPATH-mode get
We've decided to keep basic GOPATH mode running for trees that already exist, but GOPATH-mode get is being removed. It is old and not useful and probably full of security holes. See #60915 for more details. Fixes #60915. Change-Id: I9db4c445579bf0b79f6543624602652555b66c1d Reviewed-on: https://go-review.googlesource.com/c/go/+/518775 Auto-Submit: Russ Cox <[email protected]> Run-TryBot: Russ Cox <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
1 parent 16ec27b commit de4d503

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+191
-1801
lines changed

src/cmd/go/alldocs.go

Lines changed: 0 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/go/go_test.go

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,77 +1055,6 @@ func TestNewReleaseRebuildsStalePackagesInGOPATH(t *testing.T) {
10551055
tg.wantNotStale("p1", "", "./testgo list claims p1 is stale after building with old release")
10561056
}
10571057

1058-
// cmd/go: custom import path checking should not apply to Go packages without import comment.
1059-
func TestIssue10952(t *testing.T) {
1060-
testenv.MustHaveExecPath(t, "git")
1061-
1062-
tg := testgo(t)
1063-
defer tg.cleanup()
1064-
tg.parallel()
1065-
tg.acquireNet()
1066-
1067-
tg.tempDir("src")
1068-
tg.setenv("GOPATH", tg.path("."))
1069-
const importPath = "github.com/zombiezen/go-get-issue-10952"
1070-
tg.run("get", "-d", "-u", importPath)
1071-
repoDir := tg.path("src/" + importPath)
1072-
tg.runGit(repoDir, "remote", "set-url", "origin", "https://"+importPath+".git")
1073-
tg.run("get", "-d", "-u", importPath)
1074-
}
1075-
1076-
// Test git clone URL that uses SCP-like syntax and custom import path checking.
1077-
func TestIssue11457(t *testing.T) {
1078-
testenv.MustHaveExecPath(t, "git")
1079-
1080-
tg := testgo(t)
1081-
defer tg.cleanup()
1082-
tg.parallel()
1083-
tg.acquireNet()
1084-
1085-
tg.tempDir("src")
1086-
tg.setenv("GOPATH", tg.path("."))
1087-
const importPath = "rsc.io/go-get-issue-11457"
1088-
tg.run("get", "-d", "-u", importPath)
1089-
repoDir := tg.path("src/" + importPath)
1090-
tg.runGit(repoDir, "remote", "set-url", "origin", "[email protected]:rsc/go-get-issue-11457")
1091-
1092-
// At this time, custom import path checking compares remotes verbatim (rather than
1093-
// just the host and path, skipping scheme and user), so we expect go get -u to fail.
1094-
// However, the goal of this test is to verify that gitRemoteRepo correctly parsed
1095-
// the SCP-like syntax, and we expect it to appear in the error message.
1096-
tg.runFail("get", "-d", "-u", importPath)
1097-
want := " is checked out from ssh://[email protected]/rsc/go-get-issue-11457"
1098-
if !strings.HasSuffix(strings.TrimSpace(tg.getStderr()), want) {
1099-
t.Error("expected clone URL to appear in stderr")
1100-
}
1101-
}
1102-
1103-
func TestGetGitDefaultBranch(t *testing.T) {
1104-
testenv.MustHaveExecPath(t, "git")
1105-
1106-
tg := testgo(t)
1107-
defer tg.cleanup()
1108-
tg.parallel()
1109-
tg.acquireNet()
1110-
1111-
tg.tempDir("src")
1112-
tg.setenv("GOPATH", tg.path("."))
1113-
1114-
// This repo has two branches, master and another-branch.
1115-
// The another-branch is the default that you get from 'git clone'.
1116-
// The go get command variants should not override this.
1117-
const importPath = "github.com/rsc/go-get-default-branch"
1118-
1119-
tg.run("get", "-d", importPath)
1120-
repoDir := tg.path("src/" + importPath)
1121-
tg.runGit(repoDir, "branch", "--contains", "HEAD")
1122-
tg.grepStdout(`\* another-branch`, "not on correct default branch")
1123-
1124-
tg.run("get", "-d", "-u", importPath)
1125-
tg.runGit(repoDir, "branch", "--contains", "HEAD")
1126-
tg.grepStdout(`\* another-branch`, "not on correct default branch")
1127-
}
1128-
11291058
func TestPackageMainTestCompilerFlags(t *testing.T) {
11301059
tg := testgo(t)
11311060
defer tg.cleanup()
@@ -1442,35 +1371,6 @@ func TestDefaultGOPATH(t *testing.T) {
14421371
tg.grepStdoutNot(".", "want unset GOPATH because GOROOT=$HOME/go/")
14431372
}
14441373

1445-
func TestDefaultGOPATHGet(t *testing.T) {
1446-
testenv.MustHaveExecPath(t, "git")
1447-
1448-
tg := testgo(t)
1449-
defer tg.cleanup()
1450-
tg.parallel()
1451-
tg.acquireNet()
1452-
1453-
tg.setenv("GOPATH", "")
1454-
tg.tempDir("home")
1455-
tg.setenv(homeEnvName(), tg.path("home"))
1456-
1457-
// warn for creating directory
1458-
tg.run("get", "-v", "github.com/golang/example/hello")
1459-
tg.grepStderr("created GOPATH="+regexp.QuoteMeta(tg.path("home/go"))+"; see 'go help gopath'", "did not create GOPATH")
1460-
1461-
// no warning if directory already exists
1462-
tg.must(robustio.RemoveAll(tg.path("home/go")))
1463-
tg.tempDir("home/go")
1464-
tg.run("get", "github.com/golang/example/hello")
1465-
tg.grepStderrNot(".", "expected no output on standard error")
1466-
1467-
// error if $HOME/go is a file
1468-
tg.must(robustio.RemoveAll(tg.path("home/go")))
1469-
tg.tempFile("home/go", "")
1470-
tg.runFail("get", "github.com/golang/example/hello")
1471-
tg.grepStderr(`mkdir .*[/\\]go: .*(not a directory|cannot find the path)`, "expected error because $HOME/go is a file")
1472-
}
1473-
14741374
func TestDefaultGOPATHPrintedSearchList(t *testing.T) {
14751375
tg := testgo(t)
14761376
defer tg.cleanup()

0 commit comments

Comments
 (0)