Skip to content

Commit ed1b5bb

Browse files
authored
Merge pull request #2027 from lintanghui/master
fix:invalid type assert in stringArg
2 parents a034b08 + de6c131 commit ed1b5bb

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

bench_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,32 @@ func BenchmarkClusterPing(b *testing.B) {
341341
})
342342
}
343343

344+
func BenchmarkClusterDoInt(b *testing.B) {
345+
if testing.Short() {
346+
b.Skip("skipping in short mode")
347+
}
348+
349+
ctx := context.Background()
350+
cluster := newClusterScenario()
351+
if err := startCluster(ctx, cluster); err != nil {
352+
b.Fatal(err)
353+
}
354+
defer cluster.Close()
355+
356+
client := cluster.newClusterClient(ctx, redisClusterOptions())
357+
defer client.Close()
358+
359+
b.ResetTimer()
360+
b.RunParallel(func(pb *testing.PB) {
361+
for pb.Next() {
362+
err := client.Do(ctx, "SET", 10, 10).Err()
363+
if err != nil {
364+
b.Fatal(err)
365+
}
366+
}
367+
})
368+
}
369+
344370
func BenchmarkClusterSetString(b *testing.B) {
345371
if testing.Short() {
346372
b.Skip("skipping in short mode")

command.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,13 @@ func (cmd *baseCmd) stringArg(pos int) string {
151151
if pos < 0 || pos >= len(cmd.args) {
152152
return ""
153153
}
154-
s, _ := cmd.args[pos].(string)
155-
return s
154+
arg := cmd.args[pos]
155+
switch v := arg.(type) {
156+
case string:
157+
return v
158+
default:
159+
return fmt.Sprintf("%v", v)
160+
}
156161
}
157162

158163
func (cmd *baseCmd) firstKeyPos() int8 {

0 commit comments

Comments
 (0)