From bfa6b9dcef7592e6dd8225aaa0d0ab5aef5b3f84 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sun, 9 Mar 2025 20:14:46 -0400 Subject: chore(refactoring): Refactor/modernizations (#2345) chore(refactoring): Refactor with modernization refactorings * range over int * replace interface{} with any * replace common map operations with maps.Copy/maps.Clone * simplifying loops with slices.Contains/ContainsFunc * modernize benchmarks with b.Loop * modernize tests with t.Context * use fmt.Appendf * range over strings.SplitSeq * use new stdlib crypto/pbkdf2 package --------- Signed-off-by: Dave Henderson --- template.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'template.go') diff --git a/template.go b/template.go index b897ee99..0e2794ca 100644 --- a/template.go +++ b/template.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "io/fs" + "maps" "os" "path/filepath" "text/template" @@ -22,7 +23,7 @@ import ( // ignorefile name, like .gitignore const gomplateignore = ".gomplateignore" -func addTmplFuncs(f template.FuncMap, root *template.Template, tctx interface{}, path string) { +func addTmplFuncs(f template.FuncMap, root *template.Template, tctx any, path string) { t := tmpl.New(root, tctx, path) tns := func() *tmpl.Template { return t } f["tmpl"] = tns @@ -37,9 +38,8 @@ func copyFuncMap(funcMap template.FuncMap) template.FuncMap { } newFuncMap := make(template.FuncMap, len(funcMap)) - for k, v := range funcMap { - newFuncMap[k] = v - } + maps.Copy(newFuncMap, funcMap) + return newFuncMap } -- cgit v1.2.3