post: incorrect use of defer

Signed-off-by: Naman Sood <mail@nsood.in>
This commit is contained in:
Naman Sood 2021-03-19 01:31:20 -04:00
parent b59eea8657
commit 810af7fec0

View file

@ -111,14 +111,15 @@ func newPostList() (postList, error) {
} }
func insertOrUpdatePost(pl postList, p *Post) postList { func insertOrUpdatePost(pl postList, p *Post) postList {
defer sort.Sort(pl)
for i, post := range pl { for i, post := range pl {
if post.Slug == p.Slug { if post.Slug == p.Slug {
pl[i] = p pl[i] = p
sort.Sort(pl)
return pl return pl
} }
} }
pl = append(pl, p) pl = append(pl, p)
sort.Sort(pl)
return pl return pl
} }