CodeSampleX

示例

github.com/Masterminds/sprig/v3 v3.3.0

已验证示例 — golang github.com/Masterminds/sprig/v3 v3.3.0. contract 在 go 1.26 · linux alpine/x64 · docker 上运行并通过: sprig.FuncMap returns template.FuncMap…

sha256:e50f207c643b226b1a53652bff584114a1ed9b1f47113a8d83e4a000e2cc72a5

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。 MIT-0

执行证据

声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。

证据依据
签名契约通过
验证回执
1
构建过它的签名密钥
1
声明的环境 linux 24 · ubuntu · glibc 2.39 x64 go

验证运行环境

环境 契约 阶段 运行日期
go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1
2026-08-21

案例

HOW
目标
verify pkg:golang/github.com/Masterminds/sprig/v3@v3.3.0
包
创建时间
2026-08-21T02:15:35Z

契约

  1. sprig.FuncMap returns template.FuncMap containing helper functions for Go templates
  2. sprig.TxtFuncMap provides text-safe template functions that render strings with transformations
  3. sprig functions execute correctly within text/template parsing and execution for math and string operations

文件

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • main.go
  • spec.json
  • test/contract.go

下载源代码构件 (tar.gz)

源代码

PROMPT.md
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 pkg:golang/github.com/Masterminds/sprig/v3@v3.3.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/Masterminds/sprig/v3@v3.3.0

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.
csx.json
{"case":{"caseId":"case:sha256:cd03115f9ce12b801dcc48f7461cb9768dd2e8b462d125a1808a639b31596c7e","contract":["sprig.FuncMap returns template.FuncMap containing helper functions for Go templates","sprig.TxtFuncMap provides text-safe template functions that render strings with transformations","sprig functions execute correctly within text/template parsing and execution for math and string operations"],"goal":"verify pkg:golang/github.com/Masterminds/sprig/v3@v3.3.0","kind":"HOW","packages":["pkg:golang/github.com/Masterminds/sprig/v3@v3.3.0"],"schemaVersion":1},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/Masterminds/sprig/v3@v3.3.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/Masterminds/sprig/v3@v3.3.0","verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.6

require github.com/Masterminds/sprig/v3 v3.3.0

require (
	dario.cat/mergo v1.0.1 // indirect
	github.com/Masterminds/goutils v1.1.1 // indirect
	github.com/Masterminds/semver/v3 v3.3.0 // indirect
	github.com/google/uuid v1.6.0 // indirect
	github.com/huandu/xstrings v1.5.0 // indirect
	github.com/mitchellh/copystructure v1.2.0 // indirect
	github.com/mitchellh/reflectwalk v1.0.2 // indirect
	github.com/shopspring/decimal v1.4.0 // indirect
	github.com/spf13/cast v1.7.0 // indirect
	golang.org/x/crypto v0.26.0 // indirect
)
go.sum
dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
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.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs=
github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0=
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/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI=
github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/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/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
main.go
package main

import (
	"bytes"
	"fmt"
	"text/template"

	"github.com/Masterminds/sprig/v3"
)

func main() {
	tmplText := `{{ "hello world" | upper | repeat 2 }}`
	tmpl, err := template.New("example").Funcs(sprig.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())
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:golang/github.com/Masterminds/sprig/v3@v3.3.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/Masterminds/sprig/v3@v3.3.0"
  ]
}
test/contract.go
package main

import (
	"bytes"
	"fmt"
	"os"
	"text/template"

	"github.com/Masterminds/sprig/v3"
)

func main() {
	// Assertion 1: sprig.FuncMap returns template.FuncMap containing helper functions for Go templates
	funcMap := sprig.FuncMap()
	if funcMap == nil {
		fmt.Fprintln(os.Stderr, "assertion 1 failed: sprig.FuncMap returned nil")
		os.Exit(1)
	}
	if _, ok := funcMap["upper"]; !ok {
		fmt.Fprintln(os.Stderr, "assertion 1 failed: sprig.FuncMap missing 'upper' function")
		os.Exit(1)
	}
	if _, ok := funcMap["trim"]; !ok {
		fmt.Fprintln(os.Stderr, "assertion 1 failed: sprig.FuncMap missing 'trim' function")
		os.Exit(1)
	}
	if _, ok := funcMap["add"]; !ok {
		fmt.Fprintln(os.Stderr, "assertion 1 failed: sprig.FuncMap missing 'add' function")
		os.Exit(1)
	}

	// Assertion 2: sprig.TxtFuncMap provides text-safe template functions that render strings with transformations
	txtFuncMap := sprig.TxtFuncMap()
	if txtFuncMap == nil {
		fmt.Fprintln(os.Stderr, "assertion 2 failed: sprig.TxtFuncMap returned nil")
		os.Exit(1)
	}
	tmplText2 := `{{ "  sprig helper  " | trim | upper }}`
	tmpl2, err := template.New("test2").Funcs(txtFuncMap).Parse(tmplText2)
	if err != nil {
		fmt.Fprintf(os.Stderr, "assertion 2 failed to parse template: %v\n", err)
		os.Exit(1)
	}
	var buf2 bytes.Buffer
	if err := tmpl2.Execute(&buf2, nil); err != nil {
		fmt.Fprintf(os.Stderr, "assertion 2 failed to execute template: %v\n", err)
		os.Exit(1)
	}
	expected2 := "SPRIG HELPER"
	if got := buf2.String(); got != expected2 {
		fmt.Fprintf(os.Stderr, "assertion 2 failed: expected %q, got %q\n", expected2, got)
		os.Exit(1)
	}

	// Assertion 3: sprig functions execute correctly within text/template parsing and execution for math and string operations
	tmplText3 := `{{ add 10 20 }} - {{ repeat 3 "go" }}`
	tmpl3, err := template.New("test3").Funcs(funcMap).Parse(tmplText3)
	if err != nil {
		fmt.Fprintf(os.Stderr, "assertion 3 failed to parse template: %v\n", err)
		os.Exit(1)
	}
	var buf3 bytes.Buffer
	if err := tmpl3.Execute(&buf3, nil); err != nil {
		fmt.Fprintf(os.Stderr, "assertion 3 failed to execute template: %v\n", err)
		os.Exit(1)
	}
	expected3 := "30 - gogogo"
	if got := buf3.String(); got != expected3 {
		fmt.Fprintf(os.Stderr, "assertion 3 failed: expected %q, got %q\n", expected3, got)
		os.Exit(1)
	}

	fmt.Println("All contract assertions passed.")
}

原始种子者

匿名