From 0408d604d02c486000e85cfd3ae375fa28d49deb Mon Sep 17 00:00:00 2001 From: elv-jon Date: Thu, 17 May 2018 15:45:50 -0700 Subject: [PATCH] Return closed error in mem.File.Write() after Close() --- mem/file.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mem/file.go b/mem/file.go index 885e554..edd8d6f 100644 --- a/mem/file.go +++ b/mem/file.go @@ -230,6 +230,9 @@ func (f *File) Seek(offset int64, whence int) (int64, error) { } func (f *File) Write(b []byte) (n int, err error) { + if f.closed == true { + return 0, ErrFileClosed + } if f.readOnly { return 0, &os.PathError{Op: "write", Path: f.fileData.name, Err: errors.New("file handle is read only")} }