Skip to content

Commit 9b55e8f

Browse files
committed
Update 33974-add-public-lockedfile-pkg.md
add new func
1 parent 3a99c89 commit 9b55e8f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

design/33974-add-public-lockedfile-pkg.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ func Create(name string) (*File, error)
7575
// The associated file descriptor has mode O_RDWR and the file is write-locked.
7676
func Edit(name string) (*File, error)
7777
78+
// Transform invokes t with the result of reading the named file, with its lock
79+
// still held.
80+
//
81+
// If t returns a nil error, Transform then writes the returned contents back to
82+
// the file, making a best effort to preserve existing contents on error.
83+
//
84+
// t must not modify the slice passed to it.
85+
func Transform(name string, t func([]byte) ([]byte, error)) (err error) {
86+
7887
// Open is like os.Open, but returns a read-locked file.
7988
func Open(name string) (*File, error)
8089

0 commit comments

Comments
 (0)