CodeSampleX

Beispiel

github.com/glebarez/sqlite v1.11.0: Open

Verifiziertes Beispiel für golang github.com/glebarez/sqlite v1.11.0: Open. Der Vertrag lief auf go 1.26 · linux alpine/x64 · docker und bestand.

sha256:4109401222e5c22d21116b6ba7f42eb133ce05473f6a1b51d4766d1e7e6b6b49

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 alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f…
2026-08-27

Fall

HOW
Ziel
verify github.com/glebarez/sqlite.Open in pkg:golang/github.com/glebarez/sqlite@v1.11.0
Pakete
Symbole
  • github.com/glebarez/sqlite.Open
Umgebung
go 1.26.6
Erstellt
2026-08-27T23:55:46Z

Contract

  1. sqlite.Open returns a gorm.Dialector with name sqlite and the configured DSN
  2. gorm.Open with sqlite.Open establishes an in-memory SQLite database connection
  3. database auto-migration, record insertion and query operations succeed on the sqlite connection
  4. sqlite.Open with file-based DSN initializes a valid persistent database connection

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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/glebarez/sqlite.Open in pkg:golang/github.com/glebarez/sqlite@v1.11.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/glebarez/sqlite@v1.11.0
Demonstrate these symbols/APIs:
  - github.com/glebarez/sqlite.Open

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:6d41b7c1df9300bceb406c4023ad3c230f42298b1eb4e5e38974e430f3d8cc0b","contract":["sqlite.Open returns a gorm.Dialector with name sqlite and the configured DSN","gorm.Open with sqlite.Open establishes an in-memory SQLite database connection","database auto-migration, record insertion and query operations succeed on the sqlite connection","sqlite.Open with file-based DSN initializes a valid persistent database connection"],"goal":"verify github.com/glebarez/sqlite.Open in pkg:golang/github.com/glebarez/sqlite@v1.11.0","kind":"HOW","packages":["pkg:golang/github.com/glebarez/sqlite@v1.11.0"],"schemaVersion":1,"symbols":["github.com/glebarez/sqlite.Open"]},"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/glebarez/sqlite@v1.11.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/glebarez/sqlite@v1.11.0","symbols":["github.com/glebarez/sqlite.Open"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.22

require (
	github.com/dustin/go-humanize v1.0.1 // indirect
	github.com/glebarez/go-sqlite v1.21.2 // indirect
	github.com/glebarez/sqlite v1.11.0 // indirect
	github.com/google/uuid v1.3.0 // indirect
	github.com/jinzhu/inflection v1.0.0 // indirect
	github.com/jinzhu/now v1.1.5 // indirect
	github.com/mattn/go-isatty v0.0.17 // indirect
	github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
	golang.org/x/sys v0.7.0 // indirect
	gorm.io/gorm v1.25.7 // indirect
	modernc.org/libc v1.22.5 // indirect
	modernc.org/mathutil v1.5.0 // indirect
	modernc.org/memory v1.5.0 // indirect
	modernc.org/sqlite v1.23.1 // indirect
)
go.sum
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/glebarez/go-sqlite v1.21.2 h1:3a6LFC4sKahUunAmynQKLZceZCOzUthkRkEAl9gAXWo=
github.com/glebarez/go-sqlite v1.21.2/go.mod h1:sfxdZyhQjTM2Wry3gVYWaW072Ri1WMdWJi0k6+3382k=
github.com/glebarez/sqlite v1.11.0 h1:wSG0irqzP6VurnMEpFGer5Li19RpIRi2qvQz++w0GMw=
github.com/glebarez/sqlite v1.11.0/go.mod h1:h8/o8j5wiAsqSPoWELDUdJXhjAhsVliSn7bWZjOhrgQ=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gorm.io/gorm v1.25.7 h1:VsD6acwRjz2zFxGO50gPO6AkNs7KKnvfzUjHQhZDz/A=
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
modernc.org/libc v1.22.5 h1:91BNch/e5B0uPbJFgqbxXuOnxBQjlS//icfQEGmvyjE=
modernc.org/libc v1.22.5/go.mod h1:jj+Z7dTNX8fBScMVNRAYZ/jF91K8fdT2hYMThc3YjBY=
modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ=
modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/memory v1.5.0 h1:N+/8c5rE6EqugZwHii4IFsaJ7MUhoWX07J5tC/iI5Ds=
modernc.org/memory v1.5.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU=
modernc.org/sqlite v1.23.1 h1:nrSBg4aRQQwq59JpvGEQ15tNxoO5pX/kUjcRNwSAGQM=
modernc.org/sqlite v1.23.1/go.mod h1:OrDj17Mggn6MhE+iPbBNf7RGKODDE9NFT0f3EwDzJqk=
main.go
package main

import (
	"fmt"
	"log"

	"github.com/glebarez/sqlite"
	"gorm.io/gorm"
)

type User struct {
	ID    uint   `gorm:"primaryKey"`
	Name  string `gorm:"not null"`
	Email string `gorm:"uniqueIndex"`
}

func main() {
	dialector := sqlite.Open(":memory:")
	fmt.Printf("Dialector name: %s\n", dialector.Name())

	db, err := gorm.Open(dialector, &gorm.Config{})
	if err != nil {
		log.Fatalf("failed to connect to database: %v", err)
	}

	if err := db.AutoMigrate(&User{}); err != nil {
		log.Fatalf("failed to auto migrate: %v", err)
	}

	user := User{Name: "Alice", Email: "alice@example.com"}
	if result := db.Create(&user); result.Error != nil {
		log.Fatalf("failed to create user: %v", result.Error)
	}

	var found User
	if err := db.First(&found, user.ID).Error; err != nil {
		log.Fatalf("failed to find user: %v", err)
	}

	fmt.Printf("Successfully created and queried user: ID=%d, Name=%s, Email=%s\n", found.ID, found.Name, found.Email)
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify github.com/glebarez/sqlite.Open in pkg:golang/github.com/glebarez/sqlite@v1.11.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/glebarez/sqlite@v1.11.0"
  ],
  "symbols": [
    "github.com/glebarez/sqlite.Open"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"github.com/glebarez/sqlite"
	"gorm.io/gorm"
)

type Product struct {
	ID    uint   `gorm:"primaryKey"`
	Code  string `gorm:"not null"`
	Price uint   `gorm:"not null"`
}

func main() {
	// Assertion 1: sqlite.Open returns a gorm.Dialector with name sqlite and the configured DSN
	dsn := ":memory:"
	dialector := sqlite.Open(dsn)
	if dialector == nil {
		fmt.Fprintf(os.Stderr, "assertion 1 failed: sqlite.Open returned nil\n")
		os.Exit(1)
	}
	if dialector.Name() != "sqlite" {
		fmt.Fprintf(os.Stderr, "assertion 1 failed: dialector.Name() = %q, expected %q\n", dialector.Name(), "sqlite")
		os.Exit(1)
	}
	d, ok := dialector.(*sqlite.Dialector)
	if !ok {
		fmt.Fprintf(os.Stderr, "assertion 1 failed: dialector is not *sqlite.Dialector (type=%T)\n", dialector)
		os.Exit(1)
	}
	if d.DSN != dsn {
		fmt.Fprintf(os.Stderr, "assertion 1 failed: dialector DSN mismatch: got %q, expected %q\n", d.DSN, dsn)
		os.Exit(1)
	}

	// Assertion 2: gorm.Open with sqlite.Open establishes an in-memory SQLite database connection
	db, err := gorm.Open(dialector, &gorm.Config{})
	if err != nil {
		fmt.Fprintf(os.Stderr, "assertion 2 failed: gorm.Open returned error: %v\n", err)
		os.Exit(1)
	}
	if db == nil {
		fmt.Fprintf(os.Stderr, "assertion 2 failed: db is nil\n")
		os.Exit(1)
	}
	sqlDB, err := db.DB()
	if err != nil {
		fmt.Fprintf(os.Stderr, "assertion 2 failed: db.DB() returned error: %v\n", err)
		os.Exit(1)
	}
	if err := sqlDB.Ping(); err != nil {
		fmt.Fprintf(os.Stderr, "assertion 2 failed: sqlDB.Ping() returned error: %v\n", err)
		os.Exit(1)
	}

	// Assertion 3: database auto-migration, record insertion and query operations succeed on the sqlite connection
	if err := db.AutoMigrate(&Product{}); err != nil {
		fmt.Fprintf(os.Stderr, "assertion 3 failed: db.AutoMigrate returned error: %v\n", err)
		os.Exit(1)
	}
	prod := Product{Code: "PROD-101", Price: 2500}
	if result := db.Create(&prod); result.Error != nil || result.RowsAffected != 1 {
		fmt.Fprintf(os.Stderr, "assertion 3 failed: db.Create failed: err=%v, rows=%d\n", result.Error, result.RowsAffected)
		os.Exit(1)
	}
	var found Product
	if err := db.First(&found, prod.ID).Error; err != nil {
		fmt.Fprintf(os.Stderr, "assertion 3 failed: db.First failed: %v\n", err)
		os.Exit(1)
	}
	if found.Code != "PROD-101" || found.Price != 2500 {
		fmt.Fprintf(os.Stderr, "assertion 3 failed: found product mismatch: %+v\n", found)
		os.Exit(1)
	}

	// Assertion 4: sqlite.Open with file-based DSN initializes a valid persistent database connection
	fileDSN := "test_contract.db"
	defer os.Remove(fileDSN)
	fileDB, err := gorm.Open(sqlite.Open(fileDSN), &gorm.Config{})
	if err != nil {
		fmt.Fprintf(os.Stderr, "assertion 4 failed: gorm.Open with file DSN failed: %v\n", err)
		os.Exit(1)
	}
	if err := fileDB.AutoMigrate(&Product{}); err != nil {
		fmt.Fprintf(os.Stderr, "assertion 4 failed: fileDB.AutoMigrate failed: %v\n", err)
		os.Exit(1)
	}
	fileProd := Product{Code: "FILE-202", Price: 4990}
	if err := fileDB.Create(&fileProd).Error; err != nil {
		fmt.Fprintf(os.Stderr, "assertion 4 failed: fileDB.Create failed: %v\n", err)
		os.Exit(1)
	}
	var fileFound Product
	if err := fileDB.Where("code = ?", "FILE-202").First(&fileFound).Error; err != nil {
		fmt.Fprintf(os.Stderr, "assertion 4 failed: fileDB query failed: %v\n", err)
		os.Exit(1)
	}
	if fileFound.Price != 4990 {
		fmt.Fprintf(os.Stderr, "assertion 4 failed: fileDB product price mismatch: %d\n", fileFound.Price)
		os.Exit(1)
	}

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

Ursprungs-Seeder

anonym