]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: fix module replace flag parsed bug
authorBaokun Lee <nototon@gmail.com>
Fri, 13 Jul 2018 20:17:19 +0000 (04:17 +0800)
committerBryan C. Mills <bcmills@google.com>
Fri, 13 Jul 2018 22:06:20 +0000 (22:06 +0000)
In CL 122404, we change -replace syntax from => to =.
And we also need to change this and the tests.

Fixes golang/go#26373.

Change-Id: I2d4e85e10c1578540cc7673b93d849270940d776
Reviewed-on: https://go-review.googlesource.com/123778
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>

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

index d8ae1d95ac027398b54bbf721f033e7244dfe602..ddf5000dd84f2f0ba6c58f4e5bc20e247d483238 100644 (file)
@@ -400,7 +400,7 @@ func flagReplace(arg string) {
        if i = strings.Index(arg, "="); i < 0 {
                base.Fatalf("go mod: -replace=%s: need old@v=new[@v] (missing =)", arg)
        }
-       old, new := strings.TrimSpace(arg[:i]), strings.TrimSpace(arg[i+2:])
+       old, new := strings.TrimSpace(arg[:i]), strings.TrimSpace(arg[i+1:])
        if strings.HasPrefix(new, ">") {
                base.Fatalf("go mod: -replace=%s: separator between old and new is =, not =>", arg)
        }
index f3dc64cc374b8dbb3cc47c4e2767fc12a4179005..6cd9f8a948f3b29278616c6fe25af74019ffcc58 100644 (file)
@@ -383,8 +383,8 @@ func TestModEdit(t *testing.T) {
                "-droprequire=x.2",
                "-exclude=x.1 @ v1.2.0",
                "-exclude=x.1@v1.2.1",
-               "-replace=x.1@v1.3.0=>y.1@v1.4.0",
-               "-replace=x.1@v1.4.0 => ../z",
+               "-replace=x.1@v1.3.0=y.1@v1.4.0",
+               "-replace=x.1@v1.4.0 = ../z",
        )
        mustHaveGoMod(`module x.x/y/z
 
@@ -451,8 +451,8 @@ require x.3 v1.99.0
        }
 
        tg.run("mod",
-               "-replace=x.1@v1.3.0=>y.1/v2@v2.3.5",
-               "-replace=x.1@v1.4.0=>y.1/v2@v2.3.5",
+               "-replace=x.1@v1.3.0=y.1/v2@v2.3.5",
+               "-replace=x.1@v1.4.0=y.1/v2@v2.3.5",
        )
        mustHaveGoMod(`module x.x/y/z
 
@@ -466,7 +466,7 @@ replace (
 require x.3 v1.99.0
 `)
        tg.run("mod",
-               "-replace=x.1=>y.1/v2@v2.3.6",
+               "-replace=x.1=y.1/v2@v2.3.6",
        )
        mustHaveGoMod(`module x.x/y/z