Beispiel
github.com/jackc/pgx/v5 v5.10.0: CopyFromRows, CopyFromSlice, StrictNamedArgs
Verifiziertes Beispiel für golang github.com/jackc/pgx/v5 v5.10.0: CopyFromRows, CopyFromSlice, StrictNamedArgs. Der Vertrag lief auf go 1.26 · linux…
sha256:ef51dd8fdce8ad620fdc46b83a463116a8a6e4463ddffa58679525c5cb1e5762
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
windows 11 x64 go
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1 |
2026-08-19 |
Fall
HOW- Ziel
- verify pkg:golang/github.com/jackc/pgx/v5@v5.10.0
- Symbole
-
- github.com/jackc/pgx/v5.CopyFromRows
- github.com/jackc/pgx/v5.CopyFromSlice
- github.com/jackc/pgx/v5.StrictNamedArgs
- Erstellt
- 2026-08-18T20:46:34Z
Contract
- pgx.CopyFromRows initializes a CopyFromSource from slice of row values
- pgx.CopyFromRows Next and Values iterate through all rows in order
- pgx.CopyFromSlice wraps slice length and row mapping function
- pgx.CopyFromSlice correctly maps index to row values during Next iteration
- pgx.CopyFromSlice returns false on Next when reaching end of slice with nil Err
- pgx.StrictNamedArgs stores named parameters for parameterized queries
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 pkg:golang/github.com/jackc/pgx/v5@v5.10.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/jackc/pgx/v5@v5.10.0
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@11.8.0
- runtime: node@24.13.1
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:a7b50162972e636d77093535ba7fd741f155ae901422b423eb95c90a99bc105c","contract":["pgx.CopyFromRows initializes a CopyFromSource from slice of row values","pgx.CopyFromRows Next and Values iterate through all rows in order","pgx.CopyFromSlice wraps slice length and row mapping function","pgx.CopyFromSlice correctly maps index to row values during Next iteration","pgx.CopyFromSlice returns false on Next when reaching end of slice with nil Err","pgx.StrictNamedArgs stores named parameters for parameterized queries"],"goal":"verify pkg:golang/github.com/jackc/pgx/v5@v5.10.0","kind":"HOW","packages":["pkg:golang/github.com/jackc/pgx/v5@v5.10.0"],"schemaVersion":1,"symbols":["github.com/jackc/pgx/v5.CopyFromRows","github.com/jackc/pgx/v5.CopyFromSlice","github.com/jackc/pgx/v5.StrictNamedArgs"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","ecosystem":"golang","os":"windows","osVersionBucket":"11","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/jackc/pgx/v5@v5.10.0"],"schemaVersion":1,"symbols":["github.com/jackc/pgx/v5.CopyFromRows","github.com/jackc/pgx/v5.CopyFromSlice","github.com/jackc/pgx/v5.StrictNamedArgs"],"verifierAdapter":"golang@1"}
module sample
go 1.26.5
require (
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.10.0 // indirect
golang.org/x/text v0.29.0 // indirect
)
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.10.0 h1:VhSvgU2jSli8o3AqIEOTJr7rZwAEUVo4E4XhR94Zfr0=
github.com/jackc/pgx/v5 v5.10.0/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
package main
import (
"fmt"
"log"
"github.com/jackc/pgx/v5"
)
type UserRecord struct {
ID int
Name string
Email string
}
func main() {
// 1. pgx.CopyFromRows creates a CopyFromSource from a 2D slice
rawRows := [][]any{
{1, "Alice", "alice@example.com"},
{2, "Bob", "bob@example.com"},
}
rowsSource := pgx.CopyFromRows(rawRows)
rowCount := 0
for rowsSource.Next() {
vals, err := rowsSource.Values()
if err != nil {
log.Fatalf("unexpected error reading row values: %v", err)
}
rowCount++
fmt.Printf("CopyFromRows [%d]: %v\n", rowCount, vals)
}
if err := rowsSource.Err(); err != nil {
log.Fatalf("CopyFromRows iterator error: %v", err)
}
// 2. pgx.CopyFromSlice creates a CopyFromSource from a typed slice with indexing func
users := []UserRecord{
{ID: 101, Name: "Charlie", Email: "charlie@example.com"},
{ID: 102, Name: "Dana", Email: "dana@example.com"},
{ID: 103, Name: "Eve", Email: "eve@example.com"},
}
sliceSource := pgx.CopyFromSlice(len(users), func(i int) ([]any, error) {
return []any{users[i].ID, users[i].Name, users[i].Email}, nil
})
sliceCount := 0
for sliceSource.Next() {
vals, err := sliceSource.Values()
if err != nil {
log.Fatalf("unexpected error reading slice values: %v", err)
}
sliceCount++
fmt.Printf("CopyFromSlice [%d]: %v\n", sliceCount, vals)
}
if err := sliceSource.Err(); err != nil {
log.Fatalf("CopyFromSlice iterator error: %v", err)
}
// 3. pgx.StrictNamedArgs wraps query arguments requiring strict match
strictArgs := pgx.StrictNamedArgs{
"userId": 101,
"status": "active",
}
fmt.Printf("StrictNamedArgs count: %d, userId: %v\n", len(strictArgs), strictArgs["userId"])
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/github.com/jackc/pgx/v5@v5.10.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/jackc/pgx/v5@v5.10.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@11.8.0",
"runtime": "node@24.13.1"
}
}
package main
import (
"errors"
"fmt"
"os"
"github.com/jackc/pgx/v5"
)
type User struct {
ID int
Name string
Email string
}
func main() {
// Assertion 1 & 2: CopyFromRows iteration and value matching
rawRows := [][]any{
{1, "Alice", "alice@example.com"},
{2, "Bob", "bob@example.com"},
}
rowsSrc := pgx.CopyFromRows(rawRows)
if !rowsSrc.Next() {
fmt.Fprintf(os.Stderr, "FAIL: expected CopyFromRows Next() to return true for row 1\n")
os.Exit(1)
}
val1, err := rowsSrc.Values()
if err != nil || len(val1) != 3 || val1[0] != 1 || val1[1] != "Alice" || val1[2] != "alice@example.com" {
fmt.Fprintf(os.Stderr, "FAIL: CopyFromRows row 1 values mismatch: %v (err: %v)\n", val1, err)
os.Exit(1)
}
if !rowsSrc.Next() {
fmt.Fprintf(os.Stderr, "FAIL: expected CopyFromRows Next() to return true for row 2\n")
os.Exit(1)
}
val2, err := rowsSrc.Values()
if err != nil || len(val2) != 3 || val2[0] != 2 || val2[1] != "Bob" || val2[2] != "bob@example.com" {
fmt.Fprintf(os.Stderr, "FAIL: CopyFromRows row 2 values mismatch: %v (err: %v)\n", val2, err)
os.Exit(1)
}
if rowsSrc.Next() {
fmt.Fprintf(os.Stderr, "FAIL: expected CopyFromRows Next() to return false at end\n")
os.Exit(1)
}
if err := rowsSrc.Err(); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: expected CopyFromRows Err() to be nil, got: %v\n", err)
os.Exit(1)
}
// Assertion 3 & 4 & 5: CopyFromSlice mapping and iteration
users := []User{
{ID: 101, Name: "Charlie", Email: "charlie@example.com"},
{ID: 102, Name: "Dana", Email: "dana@example.com"},
{ID: 103, Name: "Eve", Email: "eve@example.com"},
}
sliceSrc := pgx.CopyFromSlice(len(users), func(i int) ([]any, error) {
if i < 0 || i >= len(users) {
return nil, errors.New("index out of range")
}
return []any{users[i].ID, users[i].Name, users[i].Email}, nil
})
expectedIDs := []int{101, 102, 103}
for i, expectedID := range expectedIDs {
if !sliceSrc.Next() {
fmt.Fprintf(os.Stderr, "FAIL: expected CopyFromSlice Next() to return true for index %d\n", i)
os.Exit(1)
}
vals, err := sliceSrc.Values()
if err != nil || len(vals) != 3 || vals[0] != expectedID {
fmt.Fprintf(os.Stderr, "FAIL: CopyFromSlice index %d mismatch: %v (err: %v)\n", i, vals, err)
os.Exit(1)
}
}
if sliceSrc.Next() {
fmt.Fprintf(os.Stderr, "FAIL: expected CopyFromSlice Next() to return false after all elements\n")
os.Exit(1)
}
if err := sliceSrc.Err(); err != nil {
fmt.Fprintf(os.Stderr, "FAIL: expected CopyFromSlice Err() to be nil, got: %v\n", err)
os.Exit(1)
}
// Assertion 6: StrictNamedArgs parameter storage
strictArgs := pgx.StrictNamedArgs{
"userId": 101,
"status": "active",
"limit": 50,
}
if len(strictArgs) != 3 || strictArgs["userId"] != 101 || strictArgs["status"] != "active" || strictArgs["limit"] != 50 {
fmt.Fprintf(os.Stderr, "FAIL: StrictNamedArgs mapping mismatch\n")
os.Exit(1)
}
fmt.Println("PASS: all contract assertions passed for pkg:golang/github.com/jackc/pgx/v5@v5.10.0")
}
Ursprungs-Seeder
anonym