type File … type osFile … // OpenFile is like os.OpenFile, but returns a locked file. // If flag includes os.O_WRONLY or os.O_RDWR, the file is write-locked; // otherwise, it is read-locked. func OpenFile(name string, flag int, perm fs.FileMode) (*File, error) { … } // Open is like os.Open, but returns a read-locked file. func Open(name string) (*File, error) { … } // Create is like os.Create, but returns a write-locked file. func Create(name string) (*File, error) { … } // Edit creates the named file with mode 0666 (before umask), // but does not truncate existing contents. // // If Edit succeeds, methods on the returned File can be used for I/O. // The associated file descriptor has mode O_RDWR and the file is write-locked. func Edit(name string) (*File, error) { … } // Close unlocks and closes the underlying file. // // Close may be called multiple times; all calls after the first will return a // non-nil error. func (f *File) Close() error { … } // Read opens the named file with a read-lock and returns its contents. func Read(name string) ([]byte, error) { … } // Write opens the named file (creating it with the given permissions if needed), // then write-locks it and overwrites it with the given content. func Write(name string, content io.Reader, perm fs.FileMode) (err error) { … } // Transform invokes t with the result of reading the named file, with its lock // still held. // // If t returns a nil error, Transform then writes the returned contents back to // the file, making a best effort to preserve existing contents on error. // // t must not modify the slice passed to it. func Transform(name string, t func([]byte) ([]byte, error)) (err error) { … }