Load user settings. todo make it is more robust, do not silent errors from the one side and todo do not make a lot of noise / spam from the other...
(c *Config)
| 79 | // todo make it is more robust, do not silent errors from the one side and |
| 80 | // todo do not make a lot of noise / spam from the other... |
| 81 | func loadUserSettings(c *Config) error { |
| 82 | userHome, _ := os.UserHomeDir() // ignore rare cases when user home is undefined |
| 83 | userConfig := filepath.Join(userHome, ".config/rhttp/config.json") |
| 84 | if _, err := os.Stat(userConfig); err != nil { |
| 85 | if errors.Is(err, os.ErrNotExist) { // it's ok if config is missed |
| 86 | return nil |
| 87 | } else { |
| 88 | return err |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | return loadJSON(userConfig, c) |
| 93 | } |
| 94 | func loadOverrideSettings(path string, c *Config) error { |
| 95 | if path == "" { |
| 96 | return nil // no config path passed |
no test coverage detected