Skip to content

Commit

Permalink
Use errors.New if the message is constant
Browse files Browse the repository at this point in the history
  • Loading branch information
stevapple committed Aug 28, 2024
1 parent 2d0905d commit 9f56f4a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sshmux.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"encoding/base64"
"errors"
"fmt"
"io"
"log"
Expand Down Expand Up @@ -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 != "" {
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 9f56f4a

Please sign in to comment.