Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change !os.IsNotExist to os.IsExist #787

wants to merge 1 commit into from


None yet
2 participants
Copy link

commented Dec 30, 2018

No description provided.


This comment has been minimized.

Copy link
Member Author

commented Dec 30, 2018

Okay... So os.IsExist(err) != !os.IsNotExist(err). I thought the contrary but looking into it, I found this gist which explains it pretty well. Basically, the methods are just error checkers, they check for errors that are expected if a file exists or doesn't.

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.

@@ -164,7 +164,7 @@ func runConfigure(configuration config.Config, flags *pflag.FlagSet) error {
workspace = config.DefaultWorkspaceDir(configuration)

// 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) {

This comment has been minimized.

Copy link

nywilken Dec 30, 2018


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).

This comment has been minimized.

Copy link

Smarticles101 Dec 30, 2018

Author Member

Yeah, I found that out lol. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.