mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 19:56:51 +08:00
Fix: reuse Current.HomeDir until go 1.13 release
This commit is contained in:
parent
ebd32c686a
commit
944fb14cd4
|
@ -2,6 +2,7 @@ package constant
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"os/user"
|
||||||
P "path"
|
P "path"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -15,9 +16,16 @@ type path struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
homedir, err := os.UserHomeDir()
|
currentUser, err := user.Current()
|
||||||
|
var homedir string
|
||||||
if err != nil {
|
if err != nil {
|
||||||
homedir, _ = os.Getwd()
|
dir := os.Getenv("HOME")
|
||||||
|
if dir == "" {
|
||||||
|
dir, _ = os.Getwd()
|
||||||
|
}
|
||||||
|
homedir = dir
|
||||||
|
} else {
|
||||||
|
homedir = currentUser.HomeDir
|
||||||
}
|
}
|
||||||
|
|
||||||
homedir = P.Join(homedir, ".config", Name)
|
homedir = P.Join(homedir, ".config", Name)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user