Dir is the configured config home directory. All the cli-related config files live in this directory.
()
| 52 | // Dir is the configured config home directory. |
| 53 | // All the cli-related config files live in this directory. |
| 54 | func Dir() string { |
| 55 | var dir string |
| 56 | if runtime.GOOS == "windows" { |
| 57 | dir = os.Getenv("APPDATA") |
| 58 | if dir != "" { |
| 59 | return filepath.Join(dir, DefaultDirName) |
| 60 | } |
| 61 | } else { |
| 62 | dir := os.Getenv("EXERCISM_CONFIG_HOME") |
| 63 | if dir != "" { |
| 64 | return dir |
| 65 | } |
| 66 | dir = os.Getenv("XDG_CONFIG_HOME") |
| 67 | if dir == "" { |
| 68 | dir = filepath.Join(os.Getenv("HOME"), ".config") |
| 69 | } |
| 70 | if dir != "" { |
| 71 | return filepath.Join(dir, DefaultDirName) |
| 72 | } |
| 73 | } |
| 74 | // If all else fails, use the current directory. |
| 75 | dir, _ = os.Getwd() |
| 76 | return dir |
| 77 | } |
| 78 | |
| 79 | func userHome() string { |
| 80 | var dir string |