os: reject WriteAt if file opened in append mode
WriteAt use pwrite syscall on *nix or WriteFile on Windows. On Linux/Windows, these system calls always write to end of file in append mode, regardless of offset parameter. It is hard (maybe impossible) to make WriteAt work portably. Making WriteAt returns an error if file is opened in append mode, we guarantee to get consistent behavior between platforms, also prevent user from accidently corrupting their data. Fixes #30716 Change-Id: If83d935a22a29eed2ff8fe53d13d0b4798aa2b81 Reviewed-on: https://go-review.googlesource.com/c/go/+/166578Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Showing
Please register or sign in to comment