getConfigPath works out the directory where the config file should be saved and returns it. does not modify the global viper
()
| 102 | // getConfigPath works out the directory where the config file should be saved and returns it. |
| 103 | // does not modify the global viper |
| 104 | func getConfigPath() (string, error) { |
| 105 | if runtime.GOOS == "windows" { |
| 106 | if appdataPath := os.Getenv(appData); appdataPath != "" { |
| 107 | configPath := filepath.Join(appdataPath, "octopus") |
| 108 | return configPath, nil |
| 109 | } else { |
| 110 | return "", fmt.Errorf("error could not find path to appdata") |
| 111 | } |
| 112 | } |
| 113 | // is unix |
| 114 | home, err := os.UserHomeDir() |
| 115 | if err != nil { |
| 116 | return "", fmt.Errorf("error could not find user home directory: %w", err) |
| 117 | } |
| 118 | configPath := filepath.Join(home, ".config", "octopus") |
| 119 | return configPath, nil |
| 120 | } |
| 121 | |
| 122 | func IsValidKey(key string) bool { |
| 123 | // Deliberate reach-out to the global viper instance here. |
no outgoing calls
no test coverage detected