|
@@ -1,8 +1,9 @@
|
|
|
|
+// +build !windows
|
|
|
|
+
|
|
package homedir
|
|
package homedir
|
|
|
|
|
|
import (
|
|
import (
|
|
"os"
|
|
"os"
|
|
- "runtime"
|
|
|
|
|
|
|
|
"github.com/opencontainers/runc/libcontainer/user"
|
|
"github.com/opencontainers/runc/libcontainer/user"
|
|
)
|
|
)
|
|
@@ -10,9 +11,6 @@ import (
|
|
// Key returns the env var name for the user's home dir based on
|
|
// Key returns the env var name for the user's home dir based on
|
|
// the platform being run on
|
|
// the platform being run on
|
|
func Key() string {
|
|
func Key() string {
|
|
- if runtime.GOOS == "windows" {
|
|
|
|
- return "USERPROFILE"
|
|
|
|
- }
|
|
|
|
return "HOME"
|
|
return "HOME"
|
|
}
|
|
}
|
|
|
|
|
|
@@ -21,7 +19,7 @@ func Key() string {
|
|
// Returned path should be used with "path/filepath" to form new paths.
|
|
// Returned path should be used with "path/filepath" to form new paths.
|
|
func Get() string {
|
|
func Get() string {
|
|
home := os.Getenv(Key())
|
|
home := os.Getenv(Key())
|
|
- if home == "" && runtime.GOOS != "windows" {
|
|
|
|
|
|
+ if home == "" {
|
|
if u, err := user.CurrentUser(); err == nil {
|
|
if u, err := user.CurrentUser(); err == nil {
|
|
return u.Home
|
|
return u.Home
|
|
}
|
|
}
|
|
@@ -32,8 +30,5 @@ func Get() string {
|
|
// GetShortcutString returns the string that is shortcut to user's home directory
|
|
// GetShortcutString returns the string that is shortcut to user's home directory
|
|
// in the native shell of the platform running on.
|
|
// in the native shell of the platform running on.
|
|
func GetShortcutString() string {
|
|
func GetShortcutString() string {
|
|
- if runtime.GOOS == "windows" {
|
|
|
|
- return "%USERPROFILE%" // be careful while using in format functions
|
|
|
|
- }
|
|
|
|
return "~"
|
|
return "~"
|
|
}
|
|
}
|