From 518c2813f96f4efcacf4a2e236402132d38950ce Mon Sep 17 00:00:00 2001 From: Yan Zhu Date: Tue, 2 Jan 2024 18:32:26 +0800 Subject: [PATCH] fix review --- client/api.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/client/api.go b/client/api.go index 47cbd770..9c295638 100644 --- a/client/api.go +++ b/client/api.go @@ -153,16 +153,13 @@ func (a api) List(ctx context.Context, result interface{}) error { if err != nil { return err } - if resultVal.IsNil() || resultVal.Cap() == 0 { - resultVal.Set(reflect.MakeSlice(resultVal.Type(), 0, len(rows))) - } } else { rows = tableCache.Rows() - // If given a null slice, fill it in the cache table completely, if not, just up to - // its capability. - if resultVal.IsNil() || resultVal.Cap() == 0 { - resultVal.Set(reflect.MakeSlice(resultVal.Type(), 0, tableCache.Len())) - } + } + // If given a null slice, fill it in the cache table completely, if not, just up to + // its capability. + if resultVal.IsNil() || resultVal.Cap() == 0 { + resultVal.Set(reflect.MakeSlice(resultVal.Type(), 0, len(rows))) } i := resultVal.Len() maxCap := resultVal.Cap()