ExpandConfigPath returns a copy of path expanded as with ExpandPath. If the path is empty, the default path is looked up inside $XDG_CONFIG_HOME, or ~/.config if that is not set.
(path, defaultPath string)
| 207 | // path is empty, the default path is looked up inside $XDG_CONFIG_HOME, or |
| 208 | // ~/.config if that is not set. |
| 209 | func ExpandConfigPath(path, defaultPath string) (string, error) { |
| 210 | if path != "" { |
| 211 | return ExpandPath(path, false) |
| 212 | } |
| 213 | |
| 214 | configHome := lookupConfigHome() |
| 215 | if configHome != "" { |
| 216 | return filepath.Join(configHome, defaultPath), nil |
| 217 | } |
| 218 | |
| 219 | return ExpandPath(fmt.Sprintf("~/.config/%s", defaultPath), false) |
| 220 | } |
| 221 | |
| 222 | // VerifyFileHash reads a file and verifies whether the SHA is correct |
| 223 | // Returns an error if there is a problem |