Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Comment on sortPosts behaviour
  • Loading branch information
tdemin committed Feb 19, 2021
1 parent cf65fcc commit ae794d9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/gmnhg/templates.go
Expand Up @@ -43,6 +43,9 @@ func mustParseTmpl(name, value string) *template.Template {
var funcMap template.FuncMap = template.FuncMap{
// sorts posts by date, newest posts go first
"sortPosts": func(posts []*post) []*post {
// sortPosts is most likely to be used in a pipeline, and the
// user has every right to expect it doesn't modify their
// existing posts slice
ps := make(postsSort, len(posts))
copy(ps, posts)
sort.Sort(ps)
Expand Down

0 comments on commit ae794d9

Please sign in to comment.