chore(repo): renamed gonf subfolder to something more traditional in go land

This commit is contained in:
Julien Dessaux 2024-03-07 00:54:35 +01:00
parent 3b9af43738
commit 560becfd32
Signed by: adyxax
GPG key ID: F92E51B86E07177E
14 changed files with 2 additions and 2 deletions

27
pkg/utils.go Normal file
View file

@ -0,0 +1,27 @@
package gonf
import (
"crypto/sha256"
)
var builtinTemplateFunctions = map[string]any{
//"encodeURIQueryParameter": url.QueryEscape,
"var": getVariable,
}
func FilterSlice[T any](slice *[]T, predicate func(T) bool) {
i := 0
for _, element := range *slice {
if predicate(element) { // if the element matches the predicate function
(*slice)[i] = element // then we keep it in the slice
i++
} // otherwise the element will get overwritten
}
*slice = (*slice)[:i] // or truncated out of the slice
}
func sha256sum(contents []byte) []byte {
h := sha256.New()
h.Write(contents)
return h.Sum(nil)
}