Fix build with go 1.24
Go 1.24 does some stricter checks now on arguments to functions accepting format strings. This commit fixes a couple of "non-constant format string in call to ..." errors when running the unit tests.
This commit is contained in:
@@ -65,12 +65,12 @@ func GenTempCertForAddr(addr string) (tls.Certificate, error) {
|
||||
// persistCertificate generates a certificate using pk as private key and proceeds to store it into a file named certName.
|
||||
func persistCertificate(certName string, l log.Logger, pk interface{}) error {
|
||||
if err := ensureExistsDir(certName); err != nil {
|
||||
return fmt.Errorf("creating certificate destination: " + certName)
|
||||
return fmt.Errorf("creating certificate destination: %s", certName)
|
||||
}
|
||||
|
||||
certificate, err := generateCertificate(pk)
|
||||
if err != nil {
|
||||
return fmt.Errorf("creating certificate: " + filepath.Dir(certName))
|
||||
return fmt.Errorf("creating certificate: %s", filepath.Dir(certName))
|
||||
}
|
||||
|
||||
certOut, err := os.Create(certName)
|
||||
@@ -108,7 +108,7 @@ func generateCertificate(pk interface{}) ([]byte, error) {
|
||||
// persistKey persists the private key used to generate the certificate at the configured location.
|
||||
func persistKey(destination string, l log.Logger, pk interface{}) error {
|
||||
if err := ensureExistsDir(destination); err != nil {
|
||||
return fmt.Errorf("creating key destination: " + destination)
|
||||
return fmt.Errorf("creating key destination: %s", destination)
|
||||
}
|
||||
|
||||
keyOut, err := os.OpenFile(destination, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ func NewTranslatorFromCommonConfig(defaultLocale string, domain string, path str
|
||||
|
||||
// Translate translates a string to the locale
|
||||
func (t Translator) Translate(str, locale string) string {
|
||||
return t.Locale(locale).Get(str)
|
||||
return t.Locale(locale).Get("%s", str)
|
||||
}
|
||||
|
||||
// Locale returns the gotext.Locale, use `.Get` method to translate strings
|
||||
|
||||
@@ -159,14 +159,14 @@ func parseAgentConfig(ae string) (string, string, error) {
|
||||
|
||||
p := strings.Split(ae, ":")
|
||||
if len(p) != 2 {
|
||||
return "", "", fmt.Errorf(fmt.Sprintf("invalid agent endpoint `%s`. expected format: `hostname:port`", ae))
|
||||
return "", "", fmt.Errorf("invalid agent endpoint `%s`. expected format: `hostname:port`", ae)
|
||||
}
|
||||
|
||||
switch {
|
||||
case p[0] == "" && p[1] == "": // case ae = ":"
|
||||
return "", "", fmt.Errorf(fmt.Sprintf("invalid agent endpoint `%s`. expected format: `hostname:port`", ae))
|
||||
return "", "", fmt.Errorf("invalid agent endpoint `%s`. expected format: `hostname:port`", ae)
|
||||
case p[0] == "":
|
||||
return "", "", fmt.Errorf(fmt.Sprintf("invalid agent endpoint `%s`. expected format: `hostname:port`", ae))
|
||||
return "", "", fmt.Errorf("invalid agent endpoint `%s`. expected format: `hostname:port`", ae)
|
||||
}
|
||||
return p[0], p[1], nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user