-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
In case the file creation fails, NewWriter returns an object implementing io.WriteCloser instead of explicit error, misleading the user that the file creation succeeded.
f, err := os.Create(name)
if err != nil {
return &failWriter{err: err}
}
To Reproduce
Try to create a file in directory without write permission to the running user.
Expected behavior
Ideally NewWriter should return an explicit error. However, that would be a breaking change.
As a workaround, we could type check the response from NewWriter and if it matches failWriter, we return an error instead of considering it as success case in the following methods:
- func (c *CommonFileSystem) Mkdir(name string, _ os.FileMode) error
- func (c *CommonFileSystem) Create(name string) (File, error)
- func (c *CommonFileSystem) handleWriteFlags(name string, flag int) (File, error)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working