]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: don't give an error for an attempt to recreate a symlink
authorIan Lance Taylor <iant@golang.org>
Fri, 4 May 2018 23:44:05 +0000 (16:44 -0700)
committerIan Lance Taylor <iant@golang.org>
Sat, 5 May 2018 00:54:52 +0000 (00:54 +0000)
When building for gccgo cmd/go uses symlinks for import maps.
In some cases, such as TestVendorTest, it generates the same symlink
multiple times. Don't give an error when this happens.

Change-Id: Iecc154ea1ac53d7c5427b36795881909c5cac7e3
Reviewed-on: https://go-review.googlesource.com/111636
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/go/internal/work/exec.go

index 7379b886cc7ff6f3f4a6ccac03c92ce0241e8f7f..c839438ba3d6578426f2d76d17e4e4ec8a9681e1 100644 (file)
@@ -1622,6 +1622,11 @@ func (b *Builder) Mkdir(dir string) error {
 
 // symlink creates a symlink newname -> oldname.
 func (b *Builder) Symlink(oldname, newname string) error {
+       // It's not an error to try to recreate an existing symlink.
+       if link, err := os.Readlink(newname); err == nil && link == oldname {
+               return nil
+       }
+
        if cfg.BuildN || cfg.BuildX {
                b.Showcmd("", "ln -s %s %s", oldname, newname)
                if cfg.BuildN {