샘플
github.com/julienschmidt/httprouter v1.3.0: Param
검증된 샘플 — golang github.com/julienschmidt/httprouter v1.3.0: Param. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다.
sha256:85ddd7601880e62d96c5c29578d9f1847f09cdfdc6470ecff48f5c22d52da2d6
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
go 1.26 linux 24 · ubuntu · glibc 2.39 amd64 go 1.26 go 1.26 go 1
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-15 |
케이스
HOW- 목표
- verify github.com/julienschmidt/httprouter.Param in pkg:golang/github.com/julienschmidt/httprouter@v1.3.0
- 심벌
-
- github.com/julienschmidt/httprouter.Param
- 환경
- go 1.26.6
- 생성일
- 2026-09-15T01:21:49Z
컨트랙트
- httprouter.Param stores URL parameter key and value pairs as exported string fields
- httprouter.Params is an ordered slice of httprouter.Param elements accessible by index
- httprouter.Params ByName retrieves the value corresponding to an existing parameter key
- httprouter.Params ByName returns an empty string when the queried key does not exist
- Router extracts named route wildcards into httprouter.Param instances passed to the Handle callback
- Router extracts multiple named route wildcards and wildcard catch-all parameters into ordered httprouter.Param elements
파일
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
소스
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/julienschmidt/httprouter.Param in pkg:golang/github.com/julienschmidt/httprouter@v1.3.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/julienschmidt/httprouter@v1.3.0
Demonstrate these symbols/APIs:
- github.com/julienschmidt/httprouter.Param
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:fd39d964f7ad25616f39703c022cf43a66857c55805285985dde9a431f27de59","contract":["httprouter.Param stores URL parameter key and value pairs as exported string fields","httprouter.Params is an ordered slice of httprouter.Param elements accessible by index","httprouter.Params ByName retrieves the value corresponding to an existing parameter key","httprouter.Params ByName returns an empty string when the queried key does not exist","Router extracts named route wildcards into httprouter.Param instances passed to the Handle callback","Router extracts multiple named route wildcards and wildcard catch-all parameters into ordered httprouter.Param elements"],"goal":"verify github.com/julienschmidt/httprouter.Param in pkg:golang/github.com/julienschmidt/httprouter@v1.3.0","kind":"HOW","packages":["pkg:golang/github.com/julienschmidt/httprouter@v1.3.0"],"schemaVersion":1,"symbols":["github.com/julienschmidt/httprouter.Param"]},"contractCommand":["go","run","./test"],"environment":{"arch":"amd64","compiler":"go","compilerVersion":"1.26.6","distro":"ubuntu","ecosystem":"golang","language":"go","languageVersion":"1.26.6","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/julienschmidt/httprouter@v1.3.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/julienschmidt/httprouter@v1.3.0","symbols":["github.com/julienschmidt/httprouter.Param"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/julienschmidt/httprouter v1.3.0
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
package main
import (
"fmt"
"net/http"
"net/http/httptest"
"github.com/julienschmidt/httprouter"
)
func main() {
router := httprouter.New()
router.GET("/users/:id", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
idParam := ps.ByName("id")
fmt.Fprintf(w, "User ID: %s\n", idParam)
for _, p := range ps {
fmt.Printf("Param key=%s value=%s\n", p.Key, p.Value)
}
})
req := httptest.NewRequest(http.MethodGet, "/users/42", nil)
rec := httptest.NewRecorder()
router.ServeHTTP(rec, req)
fmt.Printf("Status: %d, Body: %s", rec.Code, rec.Body.String())
}
{
"schemaVersion": 1,
"goal": "verify github.com/julienschmidt/httprouter.Param in pkg:golang/github.com/julienschmidt/httprouter@v1.3.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/julienschmidt/httprouter@v1.3.0"
],
"symbols": [
"github.com/julienschmidt/httprouter.Param"
]
}
package main
import (
"fmt"
"net/http"
"net/http/httptest"
"os"
"github.com/julienschmidt/httprouter"
)
func main() {
// Assertion 1: httprouter.Param stores URL parameter key and value pairs as exported string fields
{
p := httprouter.Param{
Key: "category",
Value: "books",
}
if p.Key != "category" || p.Value != "books" {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected Key='category', Value='books', got Key=%q, Value=%q\n", p.Key, p.Value)
os.Exit(1)
}
}
// Assertion 2: httprouter.Params is an ordered slice of httprouter.Param elements accessible by index
{
ps := httprouter.Params{
{Key: "section", Value: "tech"},
{Key: "article", Value: "101"},
}
if len(ps) != 2 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected len 2, got %d\n", len(ps))
os.Exit(1)
}
if ps[0].Key != "section" || ps[0].Value != "tech" {
fmt.Fprintf(os.Stderr, "assertion 2 failed: index 0 mismatch: %+v\n", ps[0])
os.Exit(1)
}
if ps[1].Key != "article" || ps[1].Value != "101" {
fmt.Fprintf(os.Stderr, "assertion 2 failed: index 1 mismatch: %+v\n", ps[1])
os.Exit(1)
}
}
// Assertion 3: httprouter.Params ByName retrieves the value corresponding to an existing parameter key
{
ps := httprouter.Params{
{Key: "lang", Value: "golang"},
{Key: "version", Value: "1.3.0"},
}
val := ps.ByName("lang")
if val != "golang" {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected 'golang', got %q\n", val)
os.Exit(1)
}
val2 := ps.ByName("version")
if val2 != "1.3.0" {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected '1.3.0', got %q\n", val2)
os.Exit(1)
}
}
// Assertion 4: httprouter.Params ByName returns an empty string when the queried key does not exist
{
ps := httprouter.Params{
{Key: "name", Value: "test"},
}
val := ps.ByName("missing")
if val != "" {
fmt.Fprintf(os.Stderr, "assertion 4 failed: expected empty string, got %q\n", val)
os.Exit(1)
}
}
// Assertion 5: Router extracts named route wildcards into httprouter.Param instances passed to the Handle callback
{
router := httprouter.New()
var capturedParams httprouter.Params
var called bool
router.GET("/items/:itemId", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
called = true
capturedParams = ps
w.WriteHeader(http.StatusOK)
})
req := httptest.NewRequest(http.MethodGet, "/items/sku-9876", nil)
rec := httptest.NewRecorder()
router.ServeHTTP(rec, req)
if !called {
fmt.Fprintf(os.Stderr, "assertion 5 failed: route handler was not called\n")
os.Exit(1)
}
if rec.Code != http.StatusOK {
fmt.Fprintf(os.Stderr, "assertion 5 failed: expected status 200, got %d\n", rec.Code)
os.Exit(1)
}
if len(capturedParams) != 1 {
fmt.Fprintf(os.Stderr, "assertion 5 failed: expected 1 param, got %d\n", len(capturedParams))
os.Exit(1)
}
p := capturedParams[0]
if p.Key != "itemId" || p.Value != "sku-9876" {
fmt.Fprintf(os.Stderr, "assertion 5 failed: param mismatch: Key=%q, Value=%q\n", p.Key, p.Value)
os.Exit(1)
}
if capturedParams.ByName("itemId") != "sku-9876" {
fmt.Fprintf(os.Stderr, "assertion 5 failed: ByName mismatch: got %q\n", capturedParams.ByName("itemId"))
os.Exit(1)
}
}
// Assertion 6: Router extracts multiple named route wildcards and wildcard catch-all parameters into ordered httprouter.Param elements
{
router := httprouter.New()
var capturedParams httprouter.Params
var called bool
router.GET("/orgs/:orgId/repos/:repoName/*subpath", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
called = true
capturedParams = ps
w.WriteHeader(http.StatusOK)
})
req := httptest.NewRequest(http.MethodGet, "/orgs/golang/repos/go/src/net/http", nil)
rec := httptest.NewRecorder()
router.ServeHTTP(rec, req)
if !called {
fmt.Fprintf(os.Stderr, "assertion 6 failed: route handler was not called\n")
os.Exit(1)
}
if len(capturedParams) != 3 {
fmt.Fprintf(os.Stderr, "assertion 6 failed: expected 3 params, got %d\n", len(capturedParams))
os.Exit(1)
}
if capturedParams[0].Key != "orgId" || capturedParams[0].Value != "golang" {
fmt.Fprintf(os.Stderr, "assertion 6 failed: param 0 mismatch: %+v\n", capturedParams[0])
os.Exit(1)
}
if capturedParams[1].Key != "repoName" || capturedParams[1].Value != "go" {
fmt.Fprintf(os.Stderr, "assertion 6 failed: param 1 mismatch: %+v\n", capturedParams[1])
os.Exit(1)
}
if capturedParams[2].Key != "subpath" || capturedParams[2].Value != "/src/net/http" {
fmt.Fprintf(os.Stderr, "assertion 6 failed: param 2 mismatch: %+v\n", capturedParams[2])
os.Exit(1)
}
}
fmt.Println("All contract assertions passed successfully.")
}
오리진 시더
익명