1
0
mirror of https://github.com/bgp/stayrtr.git synced 2024-05-06 15:54:54 +00:00

Replace redudant errors.new(fmt.sprintf with fmt.errorf(

They serve the same function, but it's more understandable what
is going on. go-static-check raises this as a warning
This commit is contained in:
Ben Cartwright-Cox
2023-01-19 12:11:02 +00:00
parent 17b7e94876
commit 029060a6a1
3 changed files with 5 additions and 5 deletions

View File

@ -164,7 +164,7 @@ func main() {
serverKeyHash := ssh.FingerprintSHA256(key)
if *ValidateSSH {
if serverKeyHash != fmt.Sprintf("SHA256:%v", *SSHServerKey) {
return errors.New(fmt.Sprintf("Server key hash %v is different than expected key hash SHA256:%v", serverKeyHash, *SSHServerKey))
return fmt.Errorf("server key hash %v is different than expected key hash SHA256:%v", serverKeyHash, *SSHServerKey)
}
}
log.Infof("Connected to server %v via ssh. Fingerprint: %v", remote.String(), serverKeyHash)

View File

@ -220,6 +220,6 @@ func (c *ClientSession) Start(addr string, connType int, configTLS *tls.Config,
case TYPE_SSH:
return c.StartSSH(addr, configSSH)
default:
return errors.New(fmt.Sprintf("Unknown type %v", connType))
return fmt.Errorf("unknown ClientSession type %v", connType)
}
}

View File

@ -32,7 +32,7 @@ func (vrp *VRPJson) GetASN2() (uint32, error) {
asnStr := strings.TrimLeft(asnc, "aAsS")
asnInt, err := strconv.ParseUint(asnStr, 10, 32)
if err != nil {
return 0, errors.New(fmt.Sprintf("Could not decode ASN string: %v", vrp.ASN))
return 0, fmt.Errorf("could not decode ASN string: %v", vrp.ASN)
}
asn := uint32(asnInt)
return asn, nil
@ -43,7 +43,7 @@ func (vrp *VRPJson) GetASN2() (uint32, error) {
case int:
return uint32(asnc), nil
default:
return 0, errors.New(fmt.Sprintf("Could not decode ASN: %v", vrp.ASN))
return 0, fmt.Errorf("could not decode ASN: %v", vrp.ASN)
}
}
@ -55,7 +55,7 @@ func (vrp *VRPJson) GetASN() uint32 {
func (vrp *VRPJson) GetPrefix2() (*net.IPNet, error) {
_, prefix, err := net.ParseCIDR(vrp.Prefix)
if err != nil {
return nil, errors.New(fmt.Sprintf("Could not decode prefix: %v", vrp.Prefix))
return nil, fmt.Errorf("could not decode prefix: %v", vrp.Prefix)
}
return prefix, nil
}