Change !os.IsNotExist to os.IsExist#787
Change !os.IsNotExist to os.IsExist#787Smarticles101 wants to merge 1 commit intoexercism:masterfrom
Conversation
|
Okay... So Since we query the file with Lstat, we expect the file to exist already, so it wouldn't throw an error if the file exists. My fault for not testing it before I pushed it, but cool to learn that. |
|
|
||
| // If it already exists don't clobber it with the default. | ||
| if _, err := os.Lstat(workspace); !os.IsNotExist(err) { | ||
| if _, err := os.Lstat(workspace); os.IsExist(err) { |
There was a problem hiding this comment.
os.Lstat will return nil if the path exist. os.IsExist requires error to be ErrExist which is why file existence is being checked with !os.IsNotExist; Lstat will always return ErrNotExist if the path is not found otherwise nil (if there are no other errors).
There was a problem hiding this comment.
Yeah, I found that out lol. Thanks!
No description provided.