Ejemplo
gorm.io/gorm 1.31.2: Run GORM on SQLite with CGO_ENABLED=0, past go-sqlite3's runtime stub error
Muestra verificada para golang gorm.io/gorm 1.31.2: Run GORM on SQLite with CGO_ENABLED=0, past go-sqlite3's runtime stub error. El contrato se ejecutó en go…
sha256:c3632f2f8dc28bb7ef59c80bcd728225b10ed65370fcd4c71af75032848b2f02
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 2
- Claves de firma que lo compilaron
- 2
Entorno declarado
go 1.26 linux · musl x64 go 1.26 go go
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1 |
2026-08-14 |
| go 1.26 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1 |
2026-08-18 |
Caso
HOW- Objetivo
- Run GORM on SQLite with CGO_ENABLED=0, past go-sqlite3's runtime stub error
- Paquetes
- Símbolos
-
- sqlite.Open
- gorm.Open
- gorm.DeletedAt
- gorm.ErrRecordNotFound
- gorm.ErrDuplicatedKey
- gorm.Config.TranslateError
- sql.Open
- sql.Drivers
- DB.Ping
- DB.AutoMigrate
- DB.Updates
- DB.Update
- DB.Select
- DB.First
- DB.Find
- DB.Unscoped
- DB.Create
- Entorno
- go 1.26
- Creado
- 2026-08-14T13:23:54Z
Contrato
- assert the build has cgo off and that there is no C compiler on PATH, so rebuilding with CGO_ENABLED=1 has nothing to invoke
- assert gorm.io/driver/sqlite still compiles and links with cgo off, since the contract binary imports it, and that its stub registers the database/sql driver name sqlite3 alongside the pure-Go engine's sqlite
- assert opening that cgo driver fails only at connection time, with go-sqlite3's Binary was compiled with CGO_ENABLED=0 stub message
- assert sql.Open on sqlite3 returns no error at all, because it does not connect, and that Ping is where the stub surfaces
- assert the linked pure-Go engine reports SQLite 3.53.3, so the forced modernc.org/sqlite pin cannot drift back to what minimal version selection would pick
- assert AutoMigrate creates the table and its deleted_at column, that running it again on an unchanged model is a no-op rather than an error, and that Create writes the auto-increment key back into the struct
- assert Updates with a struct writes the non-zero field and silently omits false and 0, returning no error and RowsAffected 1
- assert Updates with a map writes those same zero values, since a map has no zero value to be confused by
- assert Select names the columns that force a struct's zero values through
- assert Update with an explicit value writes a literal zero
- assert First on a missing row returns gorm.ErrRecordNotFound while Find returns a nil error with RowsAffected 0
- assert gorm.DeletedAt makes Delete an UPDATE: Find and First skip the row, Unscoped finds it with DeletedAt.Valid set, and a raw count shows the row still in the table
- assert reusing the primary key of a soft-deleted row fails with SQLite's own UNIQUE constraint failed: users.id message, which does not match gorm.ErrDuplicatedKey by default
- assert TranslateError makes that same conflict match gorm.ErrDuplicatedKey and replaces the driver error, so the constraint message is gone
- assert two connections to :memory: are two separate databases, so the migrated table is missing on the second one unless the pool is pinned to a single connection
Archivos
- csx.json
- go.mod
- go.sum
- src/cgo_off.go
- src/cgo_on.go
- src/store.go
- test/main.go