Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/cmd/gorename: rename failure sometimes wipes files clean #31434

Open
markvincentcaro opened this issue Apr 12, 2019 · 2 comments
Open
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@markvincentcaro
Copy link

markvincentcaro commented Apr 12, 2019

What version of Go are you using (go version)?

go version go1.12.2 windows/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\My Username\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=E:\GoCodes
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\MY USE~1\AppData\Local\Temp\go-build389077826=/tmp/go-build -gno-record-gcc-switches

What did you do?

Inside VS Code, I tried to perform a simple rename which failed for unknown reasons. I know the rename was legal because I was able to do it successfully via Find and Replace (not my preferred method of renaming something). Restoring everything and retrying the rename also works.

The intermittent error is as follows:

E:\GoCodes\src\myproject\mypackage>Finished running tool: C:\Go\bin\go.exe build -i -o C:\Users\MY USE~1\AppData\Local\Temp\vscode-goKh79E5\go-code-check myproject\mypackage

E:\GoCodes\src\myproject\mypackage>Finished running tool: E:\GoCodes\bin\golangci-lint.exe run --fast --print-issued-lines=false

E:\GoCodes\src\myproject\mypackage>Finished running tool: C:\Go\bin\go.exe vet ./...

Rename failed

Sometimes it shows the below error:

E:\GoCodes\src\myproject\mypackage>Finished running tool: C:\Go\bin\go.exe test -c -i -o C:\Users\MY USE~1\AppData\Local\Temp\vscode-goKh79E5\go-code-check myproject\mypackage

The rename failure resulted in one of the affected files getting its contents wiped clean (the file is now blank).

This issue is highly intermittent and has only happened to me twice so far (although gorename failing for unknown reasons without wiping files is more frequent).

I have no idea why gorename has the potential to completely wipe a file's contents when it can simply leave the file unchanged upon failure.

This issue is very infuriating and can set back developers hours in case their most recent changes were not saved somewhere.

What did you expect to see?

I expected one of two things:

  1. The rename should have succeeded because it was perfectly legal.

  2. In case the rename fails, no file should have its contents wiped clean.

What did you see instead?

One of the files affected by the rename had its contents wiped clean upon rename failure.

@gopherbot gopherbot added this to the Unreleased milestone Apr 12, 2019
@bcmills
Copy link
Contributor

bcmills commented Apr 12, 2019

CC @ianthehat

@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 12, 2019
@gopherbot
Copy link

Change https://golang.org/cl/170863 mentions this issue: cmd/gopherbot: CC triaged issues to owners

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants