Skip to content

Commit

Permalink
返回时,直接初始化合适的slice
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangnaiguo committed Jul 18, 2023
1 parent d8eafeb commit 3cadac3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ssdbclient/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,10 @@ func (c *connection) recv() (resp []string, err error) {
return nil, err
}
if isEnd {
max := len(c.posList) - 1
for i := 0; i < max; i += 2 {
resp = append(resp, string(c.rsp[c.posList[i]:c.posList[i+1]]))
max := len(c.posList) / 2
resp = make([]string, max)
for i := 0; i < max; i++ {
resp[i] = string(c.rsp[c.posList[i*2]:c.posList[i*2+1]])
}
break
}
Expand Down
5 changes: 5 additions & 0 deletions ssdbclient/ssdb_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ func TestSSDBClient_multiget(t *testing.T) {
t.Fatal(err)
}
defer c.Close()
if v, err := c.Do("multi_hset", "black:0", "0:0:1000565011", "2", "0:0:1001394200", "3"); err == nil {
t.Log(v)
} else {
t.Error(err)
}
if v, err := c.Do("multi_hget", "black:0", "0:0:1000565011", "0:0:1001394200"); err == nil {
t.Log(v)
} else {
Expand Down

0 comments on commit 3cadac3

Please sign in to comment.