| 77 | } |
| 78 | |
| 79 | func userHome() string { |
| 80 | var dir string |
| 81 | if runtime.GOOS == "windows" { |
| 82 | dir = os.Getenv("USERPROFILE") |
| 83 | if dir != "" { |
| 84 | return dir |
| 85 | } |
| 86 | dir = filepath.Join(os.Getenv("HOMEDRIVE"), os.Getenv("HOMEPATH")) |
| 87 | if dir != "" { |
| 88 | return dir |
| 89 | } |
| 90 | } else { |
| 91 | dir = os.Getenv("HOME") |
| 92 | if dir != "" { |
| 93 | return dir |
| 94 | } |
| 95 | } |
| 96 | // If all else fails, use the current directory. |
| 97 | dir, _ = os.Getwd() |
| 98 | return dir |
| 99 | } |
| 100 | |
| 101 | // DefaultWorkspaceDir provides a sensible default for the Exercism workspace. |
| 102 | // The default is different depending on the platform, in order to best match |