Merge pull request #167 from jslching/master

Return closed error in mem.File.Write() after Close()
This commit is contained in:
Michail Kargakis 2020-04-10 23:44:32 +02:00 committed by GitHub
commit 900cf72eec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -236,6 +236,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")}
}