refactor: switch from multierr to errors.join

This commit is contained in:
Julien Neuhart
2026-03-27 22:14:01 +01:00
parent d3a65a587c
commit ebf0548d19
9 changed files with 60 additions and 58 deletions

View File

@@ -15,7 +15,6 @@ import (
"github.com/dlclark/regexp2"
"github.com/labstack/echo/v4"
flag "github.com/spf13/pflag"
"go.uber.org/multierr"
"golang.org/x/net/http2"
"golang.org/x/sync/errgroup"
@@ -354,35 +353,35 @@ func (a *Api) Validate() error {
var err error
if a.port < 1 || a.port > 65535 {
err = multierr.Append(err,
err = errors.Join(err,
errors.New("port must be more than 1 and less than 65535"),
)
}
if a.bindIp != "" && net.ParseIP(a.bindIp) == nil {
err = multierr.Append(err, errors.New("IP must be a valid IP address"))
err = errors.Join(err, errors.New("IP must be a valid IP address"))
}
if (a.tlsCertFile != "" && a.tlsKeyFile == "") || (a.tlsCertFile == "" && a.tlsKeyFile != "") {
err = multierr.Append(err,
err = errors.Join(err,
errors.New("both TLS certificate and key files must be set"),
)
}
if !strings.HasPrefix(a.rootPath, "/") {
err = multierr.Append(err,
err = errors.Join(err,
errors.New("root path must start with /"),
)
}
if !strings.HasSuffix(a.rootPath, "/") {
err = multierr.Append(err,
err = errors.Join(err,
errors.New("root path must end with /"),
)
}
if len(strings.TrimSpace(a.correlationIdHeader)) == 0 {
err = multierr.Append(err,
err = errors.Join(err,
errors.New("trace header must not be empty"),
)
}