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:
-
The rename should have succeeded because it was perfectly legal.
-
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.
Comment From: bcmills
CC @ianthehat
Comment From: gopherbot
Change https://golang.org/cl/170863 mentions this issue: cmd/gopherbot: CC triaged issues to owners
Comment From: seankhliao
closing as obsoleted by #69360