INNER CODE UNIT · Go
expandDirs
Bharath-code/git-scope · cmd/git-scope/main.go:215
func expandDirs(dirs []string) []string {
result := make([]string, 0, len(dirs))
for _, d := range dirs {
if d == "." {
if cwd, err := os.Getwd(); err == nil {
result = append(result, cwd)
}
} else if strings.HasPrefix(d, "~/") {
if home, err := os.UserHomeDir(); err == nil {
result = append(result, filepath.Join(home, d[2:]))
}
} else if filepath.IsAbs(d) {
result = append(result, d)
} else {
if abs, err := filepath.Abs(d); err == nil {
result = append(result, abs)
}
}