From ae794d9d597ebbade3227cff982f351d182bb4fc Mon Sep 17 00:00:00 2001 From: Timur Demin Date: Fri, 19 Feb 2021 16:47:14 +0500 Subject: [PATCH] Comment on sortPosts behaviour --- cmd/gmnhg/templates.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/gmnhg/templates.go b/cmd/gmnhg/templates.go index 050cb6b..84442ca 100644 --- a/cmd/gmnhg/templates.go +++ b/cmd/gmnhg/templates.go @@ -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)