From da0f4a9dba0f537135f5c44cd22a16a8a6c24cf6 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Fri, 5 Feb 2021 12:57:29 +0000 Subject: [PATCH] Fix panic in posts limit usage (#66) * call model with limits in post * fix bug in posts handler --- posts/handler/posts.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/posts/handler/posts.go b/posts/handler/posts.go index 768a7bc..dedc380 100644 --- a/posts/handler/posts.go +++ b/posts/handler/posts.go @@ -210,7 +210,7 @@ func (p *Posts) Index(ctx context.Context, req *proto.IndexRequest, rsp *proto.I } // iterate and add - for i := 0; i <= limit; i++ { + for i := 0; i < limit; i++ { // strip the content posts[i].Content = "" rsp.Posts = append(rsp.Posts, posts[i]) @@ -256,7 +256,7 @@ func (p *Posts) Query(ctx context.Context, req *proto.QueryRequest, rsp *proto.Q } // iterate and add - for i := 0; i <= limit; i++ { + for i := 0; i < limit; i++ { rsp.Posts = append(rsp.Posts, posts[i]) }