mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
tools/benchmark/cmd: don't panic with nil values in hashKV function
hashKV checks nilness of 'eh' and 'es', but doesn't use them. Instead it panics with 'err' which is definitely nil. This should be avoided, See: https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/nilness#nilpanic This patch renames 'eh' and 'es' to 'err' in order to correct the real errors to panic. Signed-off-by: Jes Cok <xigua67damn@gmail.com>
This commit is contained in:
parent
bdbf8a2b6b
commit
27a6dd0ca5
@ -170,14 +170,14 @@ func hashKV(cmd *cobra.Command, clients []*v3.Client) {
|
||||
host := eps[0]
|
||||
|
||||
st := time.Now()
|
||||
rh, eh := clients[0].HashKV(context.Background(), host, 0)
|
||||
if eh != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to get the hashkv of endpoint %s (%v)\n", host, eh)
|
||||
rh, err := clients[0].HashKV(context.Background(), host, 0)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to get the hashkv of endpoint %s (%v)\n", host, err)
|
||||
panic(err)
|
||||
}
|
||||
rt, es := clients[0].Status(context.Background(), host)
|
||||
if es != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to get the status of endpoint %s (%v)\n", host, es)
|
||||
rt, err := clients[0].Status(context.Background(), host)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to get the status of endpoint %s (%v)\n", host, err)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user