userHomeDir returns the home directory of the current user, giving priority to the $HOME environment variable.
()
| 1351 | // userHomeDir returns the home directory of the current user, giving |
| 1352 | // priority to the $HOME environment variable. |
| 1353 | func userHomeDir() (string, error) { |
| 1354 | // First we check the environment. |
| 1355 | homedir, err := os.UserHomeDir() |
| 1356 | if err == nil { |
| 1357 | return homedir, nil |
| 1358 | } |
| 1359 | |
| 1360 | // As a fallback, we try the user information. |
| 1361 | u, err := user.Current() |
| 1362 | if err != nil { |
| 1363 | return "", xerrors.Errorf("current user: %w", err) |
| 1364 | } |
| 1365 | return u.HomeDir, nil |
| 1366 | } |
| 1367 | |
| 1368 | // UpdateHostSigner updates the host signer with a new key generated from the provided seed. |
| 1369 | // If an existing host key exists with the same algorithm, it is overwritten |
no test coverage detected