chore(repo): renamed gonf subfolder to something more traditional in go land
This commit is contained in:
parent
3b9af43738
commit
560becfd32
14 changed files with 2 additions and 2 deletions
27
pkg/utils.go
Normal file
27
pkg/utils.go
Normal 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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue