Skip to content

Commit b371f18

Browse files
joshuabezaleelrobpike
authored andcommitted
io/ioutil: update WriteFile to clarify it does not change permissions if the file exists.
The existing documentation of WriteFile does not make it clear for non-native English speakers that it will not change the permissions if the file already exists before. Fixes #35711 Change-Id: If861c3e3700957fc9ac3d5313351c57d399d3f58 Reviewed-on: https://go-review.googlesource.com/c/go/+/218417 Reviewed-by: Rob Pike <[email protected]>
1 parent bffb881 commit b371f18

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/io/ioutil/ioutil.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func ReadFile(filename string) ([]byte, error) {
7575

7676
// WriteFile writes data to a file named by filename.
7777
// If the file does not exist, WriteFile creates it with permissions perm
78-
// (before umask); otherwise WriteFile truncates it before writing.
78+
// (before umask); otherwise WriteFile truncates it before writing, without changing permissions.
7979
func WriteFile(filename string, data []byte, perm os.FileMode) error {
8080
f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm)
8181
if err != nil {

0 commit comments

Comments
 (0)