client: Use func without format

Signed-off-by: Sasha Melentyev <sasha@melentyev.io>
This commit is contained in:
Sasha Melentyev 2022-11-15 01:02:24 +03:00
parent ca8baeb308
commit 95c520976a
14 changed files with 21 additions and 20 deletions

View File

@ -54,7 +54,7 @@ func LockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) {
func open(path string, flag int, perm os.FileMode) (*os.File, error) {
if path == "" {
return nil, fmt.Errorf("cannot open empty filename")
return nil, errors.New("cannot open empty filename")
}
var access uint32
switch flag {

View File

@ -48,7 +48,7 @@ func CheckLeakedGoroutine() bool {
stackCount[normalized]++
}
fmt.Fprintf(os.Stderr, "Unexpected goroutines running after all test(s).\n")
fmt.Fprint(os.Stderr, "Unexpected goroutines running after all test(s).\n")
for stack, count := range stackCount {
fmt.Fprintf(os.Stderr, "%d instances of:\n%s\n", count, stack)
}

View File

@ -16,6 +16,7 @@ package transport
import (
"crypto/tls"
"errors"
"fmt"
"net"
"time"
@ -38,7 +39,7 @@ func NewKeepAliveListener(l net.Listener, scheme string, tlscfg *tls.Config) (ne
if scheme == "https" {
if tlscfg == nil {
return nil, fmt.Errorf("cannot listen on TLS for given listener: KeyFile and CertFile are not presented")
return nil, errors.New("cannot listen on TLS for given listener: KeyFile and CertFile are not presented")
}
return newTLSKeepaliveListener(kal, tlscfg), nil
}

View File

@ -200,7 +200,7 @@ func SelfCert(lg *zap.Logger, dirpath string, hosts []string, selfSignedCertVali
verify.Assert(lg != nil, "nil log isn't allowed")
info.Logger = lg
if selfSignedCertValidity == 0 {
err = fmt.Errorf("selfSignedCertValidity is invalid,it should be greater than 0")
err = errors.New("selfSignedCertValidity is invalid,it should be greater than 0")
info.Logger.Warn(
"cannot generate cert",
zap.Error(err),

View File

@ -18,14 +18,14 @@
package transport
import (
"fmt"
"errors"
"syscall"
"golang.org/x/sys/unix"
)
func setReusePort(network, address string, c syscall.RawConn) error {
return fmt.Errorf("port reuse is not supported on Solaris")
return errors.New("port reuse is not supported on Solaris")
}
func setReuseAddress(network, address string, conn syscall.RawConn) error {

View File

@ -18,16 +18,16 @@
package transport
import (
"fmt"
"errors"
"syscall"
)
func setReusePort(network, address string, c syscall.RawConn) error {
return fmt.Errorf("port reuse is not supported on Windows")
return errors.New("port reuse is not supported on Windows")
}
// Windows supports SO_REUSEADDR, but it may cause undefined behavior, as
// there is no protection against port hijacking.
func setReuseAddress(network, addr string, conn syscall.RawConn) error {
return fmt.Errorf("address reuse is not supported on Windows")
return errors.New("address reuse is not supported on Windows")
}

View File

@ -16,6 +16,7 @@ package transport
import (
"context"
"errors"
"fmt"
"strings"
"time"
@ -46,7 +47,7 @@ func ValidateSecureEndpoints(tlsInfo TLSInfo, eps []string) ([]string, error) {
endpoints = append(endpoints, ep)
}
if len(errs) != 0 {
err = fmt.Errorf("%s", strings.Join(errs, ","))
err = errors.New(strings.Join(errs, ","))
}
return endpoints, err
}

View File

@ -649,7 +649,7 @@ func (r *redirectFollowingHTTPClient) Do(ctx context.Context, act httpAction) (*
if resp.StatusCode/100 == 3 {
hdr := resp.Header.Get("Location")
if hdr == "" {
return nil, nil, fmt.Errorf("location header not set")
return nil, nil, errors.New("location header not set")
}
loc, err := url.Parse(hdr)
if err != nil {

View File

@ -17,7 +17,6 @@ package client
import (
"context"
"errors"
"fmt"
"io"
"math/rand"
"net/http"
@ -429,7 +428,7 @@ func TestHTTPClusterClientDo(t *testing.T) {
rand: rand.New(rand.NewSource(0)),
},
ctx: context.WithValue(context.Background(), &oneShotCtxValue, &oneShotCtxValue),
wantErr: fmt.Errorf("client: etcd member returns server error [Bad Gateway]"),
wantErr: errors.New("client: etcd member returns server error [Bad Gateway]"),
wantPinned: 1,
},
}

View File

@ -410,7 +410,7 @@ func newClient(cfg *Config) (*Client, error) {
if len(cfg.Endpoints) < 1 {
client.cancel()
return nil, fmt.Errorf("at least one Endpoint is required in client config")
return nil, errors.New("at least one Endpoint is required in client config")
}
client.SetEndpoints(cfg.Endpoints...)

View File

@ -16,7 +16,7 @@ package clientv3
import (
"context"
"fmt"
"errors"
"io"
"net"
"sync"
@ -152,7 +152,7 @@ func TestDialNoTimeout(t *testing.T) {
}
func TestIsHaltErr(t *testing.T) {
if !isHaltErr(context.TODO(), fmt.Errorf("etcdserver: some etcdserver error")) {
if !isHaltErr(context.TODO(), errors.New("etcdserver: some etcdserver error")) {
t.Errorf(`error prefixed with "etcdserver: " should be Halted by default`)
}
if isHaltErr(context.TODO(), rpctypes.ErrGRPCStopped) {

View File

@ -16,7 +16,7 @@ package concurrency
import (
"context"
"fmt"
"errors"
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
"go.etcd.io/etcd/api/v3/mvccpb"
@ -42,7 +42,7 @@ func waitDelete(ctx context.Context, client *v3.Client, key string, rev int64) e
if err := ctx.Err(); err != nil {
return err
}
return fmt.Errorf("lost watcher waiting for delete")
return errors.New("lost watcher waiting for delete")
}
// waitDeletes efficiently waits until all keys matching the prefix and no greater

View File

@ -52,7 +52,7 @@ func etcdClientDebugLevel() zapcore.Level {
}
var l zapcore.Level
if err := l.Set(envLevel); err != nil {
log.Printf("Invalid value for environment variable 'ETCD_CLIENT_DEBUG'. Using default level: 'info'")
log.Print("Invalid value for environment variable 'ETCD_CLIENT_DEBUG'. Using default level: 'info'")
return zapcore.InfoLevel
}
return l

View File

@ -408,7 +408,7 @@ func (w *watcher) RequestProgress(ctx context.Context) (err error) {
w.mu.Lock()
if w.streams == nil {
w.mu.Unlock()
return fmt.Errorf("no stream found for context")
return errors.New("no stream found for context")
}
wgs := w.streams[ctxKey]
if wgs == nil {