2
0
mirror of https://github.com/miguelmota/cointop synced 2024-11-05 00:00:14 +00:00
Former-commit-id: 2d880606660cc6319d5129d8a7d48f8f1231a0de [formerly 2d880606660cc6319d5129d8a7d48f8f1231a0de [formerly 6179667ae5fa6f8a0fd21d4fd6335ce7a7408a51 [formerly 87a5dc0da036782e4a1c160345d61f8800932fa2]]]
Former-commit-id: da0d815bdf5574054b0b91e2e9867491858baa3e
Former-commit-id: 1f979160329c2e31ba6f36ad99def98bb45896ba [formerly 72423c0f408f32b09d84a474767d5472742773e2]
Former-commit-id: 57a0192ffbdfbebf4954f70e7955fee719ca47d5
This commit is contained in:
Miguel Mota 2018-04-20 02:20:27 -07:00
parent cb37ee568e
commit cfe3ce2950

View File

@ -5,7 +5,6 @@ import (
"fmt"
"io/ioutil"
"os"
"os/user"
"strings"
"github.com/BurntSushi/toml"
@ -21,7 +20,7 @@ func (ct *Cointop) setupConfig() error {
if err != nil {
return err
}
err = ct.makeConfigFile()
Err = ct.makeConfigFile()
if err != nil {
return err
}
@ -55,12 +54,8 @@ func (ct *Cointop) loadFavoritesFromConfig() error {
}
func (ct *Cointop) configDirPath() string {
usr, err := user.Current()
if err != nil {
return ".cointop"
}
return fmt.Sprintf("%s%s", usr.HomeDir, "/.cointop")
homedir := userHomeDir()
return fmt.Sprintf("%s%s", homedir, "/.cointop")
}
func (ct *Cointop) configPath() string {
@ -172,3 +167,14 @@ func (ct *Cointop) loadShortcutsFromConfig() error {
}
return nil
}
func userHomeDir() string {
if runtime.GOOS == "windows" {
home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")
if home == "" {
home = os.Getenv("USERPROFILE")
}
return home
}
return os.Getenv("HOME")
}