From 9f56f4a553e0a8139643076374e7517dccba3542 Mon Sep 17 00:00:00 2001 From: YR Chen Date: Thu, 29 Aug 2024 01:19:42 +0800 Subject: [PATCH] Use `errors.New` if the message is constant --- sshmux.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sshmux.go b/sshmux.go index 8531a9f..ca78ab0 100644 --- a/sshmux.go +++ b/sshmux.go @@ -3,6 +3,7 @@ package main import ( "context" "encoding/base64" + "errors" "fmt" "io" "log" @@ -42,10 +43,10 @@ type upstreamInformation struct { func validateKey(config SSHKeyConfig) (ssh.Signer, error) { if config.Path == "" && config.Base64 == "" && config.Content == "" { - return nil, fmt.Errorf("one of path, base64 or content of the SSH key must be set") + return nil, errors.New("one of path, base64 or content of the SSH key must be set") } if (config.Path != "" && config.Base64 != "") || (config.Path != "" && config.Content != "") || (config.Base64 != "" && config.Content != "") { - return nil, fmt.Errorf("only one of path, base64 or content of the SSH key can be set") + return nil, errors.New("only one of path, base64 or content of the SSH key can be set") } var pemFile []byte if config.Path != "" { @@ -265,7 +266,7 @@ auth_requests: return err } if len(answers) != len(questions) { - return fmt.Errorf("ssh: numbers of answers and questions do not match") + return errors.New("ssh: numbers of answers and questions do not match") } if req.Payload == nil { req.Payload = make(map[string]string, len(challenge.Fields))