Last active
August 29, 2015 14:20
-
-
Save jdx/6dfd1c95a02beb6bb126 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func fileExists(path string) (bool, error) { | |
var err error | |
if runtime.GOOS == "windows" { | |
// Windows doesn't seem to like using os.Stat | |
_, err = os.Open(path) | |
} else { | |
_, err = os.Stat(path) | |
} | |
if err != nil { | |
if os.IsNotExist(err) { | |
return false, nil | |
} | |
return false, err | |
} | |
return true, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment