1
0
mirror of https://github.com/golang/go synced 2024-11-19 09:04:41 -07:00

cmd/go: don't give an error for an attempt to recreate a symlink

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>
This commit is contained in:
Ian Lance Taylor 2018-05-04 16:44:05 -07:00
parent 2a7e19e038
commit f7c767edc5

View 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 {