CodeSampleX

샘플

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

검증된 샘플 — golang github.com/Masterminds/sprig/v3 v3.3.0: TxtFuncMap. go 1.26 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다.

sha256:e022f51012925531ff767cd890474839180a9c400fb44665cc510c4e1bdd7e17

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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 github.com/Masterminds/sprig/v3.TxtFuncMap in pkg:golang/github.com/Masterminds/sprig/v3@v3.3.0
패키지
심벌
  • github.com/Masterminds/sprig/v3.TxtFuncMap
생성일
2026-08-21T02:20:20Z

컨트랙트

  1. sprig.TxtFuncMap returns a non-empty template.FuncMap containing text template helper functions
  2. sprig.TxtFuncMap enables text template string transformations including trimming, casing, and replacing
  3. sprig.TxtFuncMap functions execute arithmetic and collection operations correctly inside Go text templates

파일

  • 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 github.com/Masterminds/sprig/v3.TxtFuncMap in 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
Demonstrate these symbols/APIs:
  - github.com/Masterminds/sprig/v3.TxtFuncMap

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:499e62fd978061e1c86608733ba628c94c59bacf4e26dd28db98495ffcb50508","contract":["sprig.TxtFuncMap returns a non-empty template.FuncMap containing text template helper functions","sprig.TxtFuncMap enables text template string transformations including trimming, casing, and replacing","sprig.TxtFuncMap functions execute arithmetic and collection operations correctly inside Go text templates"],"goal":"verify github.com/Masterminds/sprig/v3.TxtFuncMap in 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,"symbols":["github.com/Masterminds/sprig/v3.TxtFuncMap"]},"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","symbols":["github.com/Masterminds/sprig/v3.TxtFuncMap"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.22

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 := `{{ "  sample output  " | trim | upper }}`
	tmpl, err := template.New("sample").Funcs(sprig.TxtFuncMap()).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 github.com/Masterminds/sprig/v3.TxtFuncMap in pkg:golang/github.com/Masterminds/sprig/v3@v3.3.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/Masterminds/sprig/v3@v3.3.0"
  ],
  "symbols": [
    "github.com/Masterminds/sprig/v3.TxtFuncMap"
  ]
}
test/contract.go
package main

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

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

func main() {
	// Assertion 1: sprig.TxtFuncMap returns a non-empty template.FuncMap containing text template helper functions
	fm := sprig.TxtFuncMap()
	if fm == nil {
		fmt.Fprintln(os.Stderr, "assertion 1 failed: sprig.TxtFuncMap returned nil")
		os.Exit(1)
	}
	for _, fn := range []string{"upper", "lower", "trim", "replace", "add", "sub", "list", "join"} {
		if _, ok := fm[fn]; !ok {
			fmt.Fprintf(os.Stderr, "assertion 1 failed: missing %s function\n", fn)
			os.Exit(1)
		}
	}

	// Assertion 2: sprig.TxtFuncMap enables text template string transformations including trimming, casing, and replacing
	tmplStr2 := `{{ replace "world" "sprig" ("  hello world  " | trim | lower) }}`
	t2, err := template.New("t2").Funcs(fm).Parse(tmplStr2)
	if err != nil {
		fmt.Fprintf(os.Stderr, "assertion 2 failed: %v\n", err)
		os.Exit(1)
	}
	var buf2 bytes.Buffer
	if err := t2.Execute(&buf2, nil); err != nil {
		fmt.Fprintf(os.Stderr, "assertion 2 failed: %v\n", err)
		os.Exit(1)
	}
	if got, want := buf2.String(), "hello sprig"; got != want {
		fmt.Fprintf(os.Stderr, "assertion 2 failed: got %q, want %q\n", got, want)
		os.Exit(1)
	}

	// Assertion 3: sprig.TxtFuncMap functions execute arithmetic and collection operations correctly inside Go text templates
	tmplStr3 := `{{ $sum := add 15 25 }}{{ $items := list "a" "b" "c" }}{{ $sum }}: {{ join "-" $items }}`
	t3, err := template.New("t3").Funcs(fm).Parse(tmplStr3)
	if err != nil {
		fmt.Fprintf(os.Stderr, "assertion 3 failed: %v\n", err)
		os.Exit(1)
	}
	var buf3 bytes.Buffer
	if err := t3.Execute(&buf3, nil); err != nil {
		fmt.Fprintf(os.Stderr, "assertion 3 failed: %v\n", err)
		os.Exit(1)
	}
	if got, want := buf3.String(), "40: a-b-c"; got != want {
		fmt.Fprintf(os.Stderr, "assertion 3 failed: got %q, want %q\n", got, want)
		os.Exit(1)
	}

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

오리진 시더

익명