resolvePath expands tilde and makes relative paths absolute against baseDir.
(path, baseDir string)
| 148 | |
| 149 | // resolvePath expands tilde and makes relative paths absolute against baseDir. |
| 150 | func resolvePath(path, baseDir string) (string, error) { |
| 151 | expanded, err := expandTilde(path) |
| 152 | if err != nil { |
| 153 | return "", err |
| 154 | } |
| 155 | if filepath.IsAbs(expanded) { |
| 156 | return filepath.Clean(expanded), nil |
| 157 | } |
| 158 | return filepath.Clean(filepath.Join(baseDir, expanded)), nil |
| 159 | } |
| 160 | |
| 161 | // expandTilde replaces a leading ~ with the user's home directory. |
| 162 | func expandTilde(path string) (string, error) { |
no test coverage detected