summaryrefslogtreecommitdiff
path: root/src/cmd/gofmt/doc.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2016-11-10 14:40:32 -0800
committerRobert Griesemer <gri@golang.org>2016-11-10 23:40:07 +0000
commit35ea53dcc8d8350898250e87a0b5ffa03e14173e (patch)
treeb6f1dd21d6c8684bc917c93e80db1c5298c8872a /src/cmd/gofmt/doc.go
parent0457957c991dde4bbdeefb73bc9fb01827298bd9 (diff)
downloadgo-git-35ea53dcc8d8350898250e87a0b5ffa03e14173e.tar.gz
cmd/gofmt: don't overwrite read-only files
This reverts the changes from https://golang.org/cl/33018: Instead of writing the result of gofmt to a tmp file and then rename that to the original (which doesn't preserve the original file's perm bits, uid, gid, and possibly other properties because it is hard to do in a platform-independent way - see #17869), use the original code that simply overwrites the processed file if gofmt was able to create a backup first. Upon success, the backup is removed, otherwise it remains. Fixes #17873. For #8984. Change-Id: Ifcf2bf1f84f730e6060f3517d63b45eb16215ae1 Reviewed-on: https://go-review.googlesource.com/33098 Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/gofmt/doc.go')
-rw-r--r--src/cmd/gofmt/doc.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/cmd/gofmt/doc.go b/src/cmd/gofmt/doc.go
index 9d0cd32862..805e5fbdcf 100644
--- a/src/cmd/gofmt/doc.go
+++ b/src/cmd/gofmt/doc.go
@@ -32,7 +32,8 @@ The flags are:
-w
Do not print reformatted sources to standard output.
If a file's formatting is different from gofmt's, overwrite it
- with gofmt's version.
+ with gofmt's version. If an error occured during overwriting,
+ the orginal file is restored from an automatic backup.
Debugging support:
-cpuprofile filename
@@ -98,3 +99,5 @@ This may result in changes that are incompatible with earlier versions of Go.
package main
// BUG(rsc): The implementation of -r is a bit slow.
+// BUG(gri): If -w fails, the restored original file may not have some of the
+// original file attributes.