chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994)

This PR replaces unnecessary calls to formatting functions (`fmt.Printf`, `fmt.Errorf`, ...) by non-formatting equivalents.
Resolves #7967

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7994
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: chavacava <chavacava@noreply.codeberg.org>
Co-committed-by: chavacava <chavacava@noreply.codeberg.org>
This commit is contained in:
chavacava 2025-05-29 17:34:29 +02:00 committed by Gusted
commit 99d697263f
126 changed files with 340 additions and 281 deletions

View file

@ -12,6 +12,7 @@ import (
"crypto/x509"
"encoding/base64"
"encoding/pem"
"errors"
"fmt"
"hash"
"math/big"
@ -121,7 +122,7 @@ func verifyTimestamp(req *http.Request) error {
}
if diff > maxTimeDifference {
return fmt.Errorf("time difference")
return errors.New("time difference")
}
return nil
@ -190,7 +191,7 @@ func getAuthorizationData(req *http.Request) ([]byte, error) {
tmp := make([]string, len(valueList))
for k, v := range valueList {
if k > len(tmp) {
return nil, fmt.Errorf("invalid X-Ops-Authorization headers")
return nil, errors.New("invalid X-Ops-Authorization headers")
}
tmp[k-1] = v
}
@ -267,7 +268,7 @@ func verifyDataOld(signature, data []byte, pub *rsa.PublicKey) error {
}
if !slices.Equal(out[skip:], data) {
return fmt.Errorf("could not verify signature")
return errors.New("could not verify signature")
}
return nil