package paths import ( "path/filepath" ) // Expand resolves shell-like shortcuts in a path string: // - empty string resolves to the user's home directory // - leading '~' expands to the user's home directory func Expand(dir string) string { // Empty string resolves to the users home dir. if len(dir) < 1 { return HomeDir() } // Expand ~ to users home dir. if dir[0] == '~' { return filepath.Join(HomeDir(), dir[1:]) } return dir }