EnsureAbsPath takes a clean path and forces it to be absolute. If it fails to get absolute path (rare), it checks if it's already absolute, otherwise relies on the input.
(path string)
| 9 | // If it fails to get absolute path (rare), it checks if it's already absolute, |
| 10 | // otherwise relies on the input. |
| 11 | func EnsureAbsPath(path string) string { |
| 12 | if path == "" { |
| 13 | path = "." |
| 14 | } |
| 15 | if abs, err := filepath.Abs(path); err == nil { |
| 16 | return abs |
| 17 | } |
| 18 | return path |
| 19 | } |
| 20 | |
| 21 | // IsWindowsAbsPath reports whether p looks like a Windows absolute path even |
| 22 | // when running on a non-Windows host (for example inside Docker on Linux). |
no outgoing calls