Skip to content

Commit 00f32fb

Browse files
oioojBryan C. Mills
authored and
Bryan C. Mills
committed
cmd/go: fix module replace flag parsed bug
In CL 122404, we change -replace syntax from => to =. And we also need to change this and the tests. Fixes #26373. Change-Id: I2d4e85e10c1578540cc7673b93d849270940d776 Reviewed-on: https://go-review.googlesource.com/123778 Reviewed-by: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]>
1 parent 5e60479 commit 00f32fb

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/cmd/go/internal/modcmd/mod.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ func flagReplace(arg string) {
400400
if i = strings.Index(arg, "="); i < 0 {
401401
base.Fatalf("go mod: -replace=%s: need old@v=new[@v] (missing =)", arg)
402402
}
403-
old, new := strings.TrimSpace(arg[:i]), strings.TrimSpace(arg[i+2:])
403+
old, new := strings.TrimSpace(arg[:i]), strings.TrimSpace(arg[i+1:])
404404
if strings.HasPrefix(new, ">") {
405405
base.Fatalf("go mod: -replace=%s: separator between old and new is =, not =>", arg)
406406
}

src/cmd/go/mod_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,8 @@ func TestModEdit(t *testing.T) {
383383
"-droprequire=x.2",
384384
"-exclude=x.1 @ v1.2.0",
385385
386-
387-
"[email protected] => ../z",
386+
387+
388388
)
389389
mustHaveGoMod(`module x.x/y/z
390390
@@ -451,8 +451,8 @@ require x.3 v1.99.0
451451
}
452452

453453
tg.run("mod",
454-
455-
454+
455+
456456
)
457457
mustHaveGoMod(`module x.x/y/z
458458
@@ -466,7 +466,7 @@ replace (
466466
require x.3 v1.99.0
467467
`)
468468
tg.run("mod",
469-
"-replace=x.1=>y.1/[email protected]",
469+
"-replace=x.1=y.1/[email protected]",
470470
)
471471
mustHaveGoMod(`module x.x/y/z
472472

0 commit comments

Comments
 (0)