From a3e10757a52fa47a0608afd88986162ca5eb22cc Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 23 Feb 2024 15:01:41 +0200 Subject: lint warnings --- internal/ssh/client/clientkeypair.go | 3 +-- internal/ssh/client/knownhostscallback.go | 8 ++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'internal/ssh/client') diff --git a/internal/ssh/client/clientkeypair.go b/internal/ssh/client/clientkeypair.go index b35b25d..20cdc88 100644 --- a/internal/ssh/client/clientkeypair.go +++ b/internal/ssh/client/clientkeypair.go @@ -6,7 +6,6 @@ import ( "crypto/x509" "encoding/pem" "fmt" - "io/ioutil" "os" "github.com/mimecast/dtail/internal/io/dlog" @@ -83,7 +82,7 @@ func generatePublicKey(privatekey *rsa.PublicKey) ([]byte, error) { } func writeKey(keyBytes []byte, saveFileTo string) error { - err := ioutil.WriteFile(saveFileTo, keyBytes, 0600) + err := os.WriteFile(saveFileTo, keyBytes, 0600) if err != nil { return err } diff --git a/internal/ssh/client/knownhostscallback.go b/internal/ssh/client/knownhostscallback.go index 393c4c7..fe3543c 100644 --- a/internal/ssh/client/knownhostscallback.go +++ b/internal/ssh/client/knownhostscallback.go @@ -232,8 +232,12 @@ func (c KnownHostsCallback) trustHosts(hosts []unknownHost) { // And once as [IP]:PORT addresses[knownhosts.Normalize(unknown.remote.String())] = struct{}{} - newFd.WriteString(fmt.Sprintf("%s\n", unknown.hostLine)) - newFd.WriteString(fmt.Sprintf("%s\n", unknown.ipLine)) + if _, err := newFd.WriteString(fmt.Sprintf("%s\n", unknown.hostLine)); err != nil { + panic(err) + } + if _, err := newFd.WriteString(fmt.Sprintf("%s\n", unknown.ipLine)); err != nil { + panic(err) + } } // Read old known hosts file, to see which are old and new entries -- cgit v1.2.3