• Robert Griesemer's avatar
    cmd/gofmt: don't overwrite read-only files · 35ea53dc
    Robert Griesemer authored
    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: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    35ea53dc
Name
Last commit
Last update
..
testdata Loading commit data...
doc.go Loading commit data...
gofmt.go Loading commit data...
gofmt_test.go Loading commit data...
internal.go Loading commit data...
long_test.go Loading commit data...
rewrite.go Loading commit data...
simplify.go Loading commit data...