Remove UUID

This commit is contained in:
binwiederhier
2025-07-19 15:44:49 +02:00
parent ae62e0d955
commit 57df16dd62
7 changed files with 4 additions and 50 deletions

View File

@@ -7,8 +7,6 @@ import (
"encoding/hex"
"fmt"
"hash/adler32"
"github.com/google/uuid"
)
func sha512sum(input string) string {
@@ -30,8 +28,3 @@ func adler32sum(input string) string {
hash := adler32.Checksum([]byte(input))
return fmt.Sprintf("%d", hash)
}
// uuidv4 provides a safe and secure UUID v4 implementation
func uuidv4() string {
return uuid.New().String()
}

View File

@@ -31,24 +31,3 @@ func TestAdler32Sum(t *testing.T) {
t.Error(err)
}
}
func TestUUIDGeneration(t *testing.T) {
tpl := `{{uuidv4}}`
out, err := runRaw(tpl, nil)
if err != nil {
t.Error(err)
}
if len(out) != 36 {
t.Error("Expected UUID of length 36")
}
out2, err := runRaw(tpl, nil)
if err != nil {
t.Error(err)
}
if out == out2 {
t.Error("Expected subsequent UUID generations to be different")
}
}

View File

@@ -58,10 +58,7 @@ var genericMap = map[string]any{
},
"substr": substring,
// Switch order so that "foo" | repeat 5
"repeat": func(count int, str string) string { return strings.Repeat(str, count) },
// Deprecated: Use trimAll.
"trimall": func(a, b string) string { return strings.Trim(b, a) },
// Switch order so that "$foo" | trimall "$"
"repeat": func(count int, str string) string { return strings.Repeat(str, count) },
"trimAll": func(a, b string) string { return strings.Trim(b, a) },
"trimSuffix": func(a, b string) string { return strings.TrimSuffix(b, a) },
"trimPrefix": func(a, b string) string { return strings.TrimPrefix(b, a) },
@@ -220,9 +217,6 @@ var genericMap = map[string]any{
"chunk": chunk,
"mustChunk": mustChunk,
// UUIDs:
"uuidv4": uuidv4,
// Flow Control:
"fail": func(msg string) (string, error) { return "", errors.New(msg) },