(p string)
| 14 | ) |
| 15 | |
| 16 | func AbsolutePath(p string) (string, error) { |
| 17 | |
| 18 | if strings.HasPrefix(p, "~") { |
| 19 | home := os.Getenv("HOME") |
| 20 | if home == "" { |
| 21 | panic(fmt.Sprintf("can not found HOME in envs, '%s' AbsPh Failed!", p)) |
| 22 | } |
| 23 | p = fmt.Sprint(home, string(p[1:])) |
| 24 | } |
| 25 | s, err := filepath.Abs(p) |
| 26 | |
| 27 | if nil != err { |
| 28 | return "", err |
| 29 | } |
| 30 | return s, nil |
| 31 | } |
| 32 | |
| 33 | // FileExists reports whether the named file or directory exists. |
| 34 | func FileExists(name string) bool { |