Return closed error in mem.File.Write() after Close()

This commit is contained in:
elv-jon 2018-05-17 15:45:50 -07:00
parent 63644898a8
commit 0408d604d0
1 changed files with 3 additions and 0 deletions

View File

@ -230,6 +230,9 @@ func (f *File) Seek(offset int64, whence int) (int64, error) {
} }
func (f *File) Write(b []byte) (n int, err error) { func (f *File) Write(b []byte) (n int, err error) {
if f.closed == true {
return 0, ErrFileClosed
}
if f.readOnly { if f.readOnly {
return 0, &os.PathError{Op: "write", Path: f.fileData.name, Err: errors.New("file handle is read only")} return 0, &os.PathError{Op: "write", Path: f.fileData.name, Err: errors.New("file handle is read only")}
} }