post: incorrect use of defer
Signed-off-by: Naman Sood <mail@nsood.in>
This commit is contained in:
parent
b59eea8657
commit
810af7fec0
1 changed files with 2 additions and 1 deletions
3
post.go
3
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue