Beispiel
github.com/Masterminds/sprig/v3 v3.2.3: GenericFuncMap
Verifiziertes Beispiel für golang github.com/Masterminds/sprig/v3 v3.2.3: GenericFuncMap. Der Vertrag lief auf go 1.26 · linux debian/x64 · docker und…
sha256:3caf122d0d068ed765c141bd57e33bb51f81a22f75a4ab4c31947e29884a6e5c
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-09-04 |
Fall
HOW- Ziel
- verify github.com/Masterminds/sprig/v3.GenericFuncMap in pkg:golang/github.com/Masterminds/sprig/v3@v3.2.3
- Symbole
-
- github.com/Masterminds/sprig/v3.GenericFuncMap
- Umgebung
- go 1.26.6
- Erstellt
- 2026-09-04T13:41:06Z
Contract
- sprig.GenericFuncMap returns map[string]interface{} containing standard template functions
- sprig.GenericFuncMap returns a mutable copy that isolates modifications from subsequent calls
- sprig.GenericFuncMap can be converted to text/template.FuncMap and html/template.FuncMap to execute template pipelines
Dateien
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Quelltext
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify github.com/Masterminds/sprig/v3.GenericFuncMap in pkg:golang/github.com/Masterminds/sprig/v3@v3.2.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/Masterminds/sprig/v3@v3.2.3
Demonstrate these symbols/APIs:
- github.com/Masterminds/sprig/v3.GenericFuncMap
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:781d84e619918bf88de1df4143b2a7148fc48af3ae087e3f7de6ab52d3947786","contract":["sprig.GenericFuncMap returns map[string]interface{} containing standard template functions","sprig.GenericFuncMap returns a mutable copy that isolates modifications from subsequent calls","sprig.GenericFuncMap can be converted to text/template.FuncMap and html/template.FuncMap to execute template pipelines"],"goal":"verify github.com/Masterminds/sprig/v3.GenericFuncMap in pkg:golang/github.com/Masterminds/sprig/v3@v3.2.3","kind":"HOW","packages":["pkg:golang/github.com/Masterminds/sprig/v3@v3.2.3"],"schemaVersion":1,"symbols":["github.com/Masterminds/sprig/v3.GenericFuncMap"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/Masterminds/sprig/v3@v3.2.3"],"schemaVersion":1,"subject":"pkg:golang/github.com/Masterminds/sprig/v3@v3.2.3","symbols":["github.com/Masterminds/sprig/v3.GenericFuncMap"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require github.com/Masterminds/sprig/v3 v3.2.3
require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
golang.org/x/crypto v0.3.0 // indirect
)
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g=
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA=
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4=
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY=
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A=
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
package main
import (
"bytes"
"fmt"
ttemplate "text/template"
"github.com/Masterminds/sprig/v3"
)
func main() {
// sprig.GenericFuncMap returns a map[string]interface{} containing all sprig template functions
funcMap := sprig.GenericFuncMap()
// Add custom function to the generic func map
funcMap["customPrefix"] = func(s string) string {
return "pref:" + s
}
tmplText := `{{ customPrefix "item" }} | {{ "hello" | upper }} | {{ add 15 27 }}`
tmpl, err := ttemplate.New("example").Funcs(ttemplate.FuncMap(funcMap)).Parse(tmplText)
if err != nil {
panic(err)
}
var buf bytes.Buffer
if err := tmpl.Execute(&buf, nil); err != nil {
panic(err)
}
fmt.Println(buf.String())
}
{
"schemaVersion": 1,
"goal": "verify github.com/Masterminds/sprig/v3.GenericFuncMap in pkg:golang/github.com/Masterminds/sprig/v3@v3.2.3",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/Masterminds/sprig/v3@v3.2.3"
],
"symbols": [
"github.com/Masterminds/sprig/v3.GenericFuncMap"
]
}
package main
import (
"bytes"
"fmt"
htemplate "html/template"
"os"
ttemplate "text/template"
"github.com/Masterminds/sprig/v3"
)
func main() {
// Assertion 1: sprig.GenericFuncMap returns map[string]interface{} containing standard template functions
funcMap := sprig.GenericFuncMap()
if funcMap == nil {
fmt.Fprintln(os.Stderr, "assertion 1 failed: sprig.GenericFuncMap returned nil")
os.Exit(1)
}
for _, expectedKey := range []string{"upper", "trim", "add", "list", "hello"} {
if _, ok := funcMap[expectedKey]; !ok {
fmt.Fprintf(os.Stderr, "assertion 1 failed: missing expected function %q in GenericFuncMap\n", expectedKey)
os.Exit(1)
}
}
helloFn, ok := funcMap["hello"].(func() string)
if !ok {
fmt.Fprintln(os.Stderr, "assertion 1 failed: 'hello' is not a func() string")
os.Exit(1)
}
if got := helloFn(); got != "Hello!" {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected hello() = %q, got %q\n", "Hello!", got)
os.Exit(1)
}
// Assertion 2: sprig.GenericFuncMap returns a mutable copy that isolates modifications from subsequent calls
funcMap1 := sprig.GenericFuncMap()
funcMap1["custom_isolated_test_key"] = func() string { return "isolated" }
delete(funcMap1, "upper")
funcMap2 := sprig.GenericFuncMap()
if _, exists := funcMap2["custom_isolated_test_key"]; exists {
fmt.Fprintln(os.Stderr, "assertion 2 failed: mutation leaked into subsequent GenericFuncMap() call")
os.Exit(1)
}
if _, exists := funcMap2["upper"]; !exists {
fmt.Fprintln(os.Stderr, "assertion 2 failed: deletion affected subsequent GenericFuncMap() call")
os.Exit(1)
}
// Assertion 3: sprig.GenericFuncMap can be converted to text/template.FuncMap and html/template.FuncMap to execute template pipelines
tFuncMap := ttemplate.FuncMap(sprig.GenericFuncMap())
tmplText := `{{ list "apple" "banana" "cherry" | join ", " | upper }}`
tTmpl, err := ttemplate.New("tTest").Funcs(tFuncMap).Parse(tmplText)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 3 failed to parse text/template: %v\n", err)
os.Exit(1)
}
var tBuf bytes.Buffer
if err := tTmpl.Execute(&tBuf, nil); err != nil {
fmt.Fprintf(os.Stderr, "assertion 3 failed to execute text/template: %v\n", err)
os.Exit(1)
}
expectedText := "APPLE, BANANA, CHERRY"
if got := tBuf.String(); got != expectedText {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected %q, got %q\n", expectedText, got)
os.Exit(1)
}
hFuncMap := htemplate.FuncMap(sprig.GenericFuncMap())
hTmplText := `{{ add 15 27 }}`
hTmpl, err := htemplate.New("hTest").Funcs(hFuncMap).Parse(hTmplText)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 3 failed to parse html/template: %v\n", err)
os.Exit(1)
}
var hBuf bytes.Buffer
if err := hTmpl.Execute(&hBuf, nil); err != nil {
fmt.Fprintf(os.Stderr, "assertion 3 failed to execute html/template: %v\n", err)
os.Exit(1)
}
expectedHtml := "42"
if got := hBuf.String(); got != expectedHtml {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected %q, got %q\n", expectedHtml, got)
os.Exit(1)
}
fmt.Println("All contract assertions passed.")
}
Ursprungs-Seeder
anonym