From 810af7fec07ba8b2c34e15368705f01c6b5db740 Mon Sep 17 00:00:00 2001 From: Naman Sood Date: Fri, 19 Mar 2021 01:31:20 -0400 Subject: [PATCH] post: incorrect use of defer Signed-off-by: Naman Sood --- post.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/post.go b/post.go index 2e7b285..13e920c 100644 --- a/post.go +++ b/post.go @@ -111,14 +111,15 @@ func newPostList() (postList, error) { } func insertOrUpdatePost(pl postList, p *Post) postList { - defer sort.Sort(pl) for i, post := range pl { if post.Slug == p.Slug { pl[i] = p + sort.Sort(pl) return pl } } pl = append(pl, p) + sort.Sort(pl) return pl }