Skip to content

Commit

Permalink
use os UserHomeDir instead of os/user.
Browse files Browse the repository at this point in the history
  • Loading branch information
melbahja committed Nov 17, 2020
1 parent 818c208 commit 38d5ac7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"net"
"os"
"os/user"

"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/knownhosts"
Expand Down Expand Up @@ -107,10 +106,10 @@ func AddKnownHost(host string, remote net.Addr, key ssh.PublicKey, knownFile str
// DefaultKnownHostsPath returns default user knows hosts file.
func DefaultKnownHostsPath() (string, error) {

user, err := user.Current()
home, err := os.UserHomeDir()
if err != nil {
return "", err
}

return fmt.Sprintf("%s/.ssh/known_hosts", user.HomeDir), err
return fmt.Sprintf("%s/.ssh/known_hosts", home), err
}

0 comments on commit 38d5ac7

Please sign in to comment.