Created
April 7, 2016 02:23
-
-
Save xigang/c52cbd5c03f69e84be7729e75c31e307 to your computer and use it in GitHub Desktop.
判断路径及文件是否存在
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
| // internal utility methods | |
| func webTime(t time.Time) string { | |
| ftime := t.Format(time.RFC1123) | |
| if strings.HasSuffix(ftime, "UTC") { | |
| ftime = ftime[0:len(ftime)-3] + "GMT" | |
| } | |
| return ftime | |
| } | |
| func dirExists(dir string) bool { | |
| d, e := os.Stat(dir) | |
| switch { | |
| case e != nil: | |
| return false | |
| case !d.IsDir(): | |
| return false | |
| } | |
| return true | |
| } | |
| func fileExists(dir string) bool { | |
| info, err := os.Stat(dir) | |
| if err != nil { | |
| return false | |
| } | |
| return !info.IsDir() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment