Created
January 29, 2015 11:07
-
-
Save toashd/ee105034c763a65c5534 to your computer and use it in GitHub Desktop.
Go check if file exists
This file contains hidden or 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
| // Exists reports whether the named file or directory exists. | |
| func Exists(name string) bool { | |
| if _, err := os.Stat(name); err != nil { | |
| if os.IsNotExist(err) { | |
| return false | |
| } | |
| } | |
| return true | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment