CodeSampleX

Sample

github.com/go-sql-driver/mysql v1.7.1: RegisterTLSConfig

Verified sample for golang github.com/go-sql-driver/mysql v1.7.1: RegisterTLSConfig. The contract ran on go 1.26 · linux alpine/x64 · docker and passed.

sha256:04112e9cd65e152f282c5d0df6d99a5a1dba43a6c101d90aed4c267d97b0831d

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
2
Signing keys that built it
1
Declared environment go 1.26 linux 24 · alpine · musl amd64 go 1.26 go go 1

Verification-run environments

Environment Contract Stages Run
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-26
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-09-07

Case

HOW
Goal
verify github.com/go-sql-driver/mysql.RegisterTLSConfig in pkg:golang/github.com/go-sql-driver/mysql@v1.7.1
Packages
Symbols
  • github.com/go-sql-driver/mysql.RegisterTLSConfig
Environment
go 1.26
Created
2026-08-26T01:43:16Z

Contract

  1. RegisterTLSConfig registers a custom *tls.Config under a custom key name
  2. RegisterTLSConfig returns an error when attempting to register a reserved key
  3. DeregisterTLSConfig removes a registered TLS configuration

Files

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

Download the source artifact (tar.gz)

Source

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/go-sql-driver/mysql.RegisterTLSConfig in pkg:golang/github.com/go-sql-driver/mysql@v1.7.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/go-sql-driver/mysql@v1.7.1
Demonstrate these symbols/APIs:
  - github.com/go-sql-driver/mysql.RegisterTLSConfig
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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:feb753fd0be5b1017c73dc9a57621f0c2b5d4aa4f459c06c8de300403d465373","contract":["RegisterTLSConfig registers a custom *tls.Config under a custom key name","RegisterTLSConfig returns an error when attempting to register a reserved key","DeregisterTLSConfig removes a registered TLS configuration"],"goal":"verify github.com/go-sql-driver/mysql.RegisterTLSConfig in pkg:golang/github.com/go-sql-driver/mysql@v1.7.1","kind":"HOW","packages":["pkg:golang/github.com/go-sql-driver/mysql@v1.7.1"],"schemaVersion":1,"symbols":["github.com/go-sql-driver/mysql.RegisterTLSConfig"]},"contractCommand":["go","test","./..."],"environment":{"arch":"amd64","distro":"alpine","ecosystem":"golang","language":"go","libc":"musl","moduleSystem":"gomod","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26","runtime":"go","runtimeVersion":"1.26","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/go-sql-driver/mysql@v1.7.1"],"schemaVersion":1,"subject":"pkg:golang/github.com/go-sql-driver/mysql@v1.7.1","symbols":["github.com/go-sql-driver/mysql.RegisterTLSConfig"],"verifierAdapter":"golang@1"}
go.mod
module sample

go 1.26.6

require github.com/go-sql-driver/mysql v1.7.1
go.sum
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
main.go
package main

import (
	"crypto/tls"
	"fmt"

	"github.com/go-sql-driver/mysql"
)

func main() {
	tlsConfig := &tls.Config{
		MinVersion: tls.VersionTLS12,
	}
	err := mysql.RegisterTLSConfig("custom-tls", tlsConfig)
	if err != nil {
		panic(err)
	}
	defer mysql.DeregisterTLSConfig("custom-tls")

	cfg, err := mysql.ParseDSN("user:pass@tcp(127.0.0.1:3306)/dbname?tls=custom-tls")
	if err != nil {
		panic(err)
	}

	fmt.Printf("DSN parsed with TLS: %s\n", cfg.TLSConfig)
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify github.com/go-sql-driver/mysql.RegisterTLSConfig in pkg:golang/github.com/go-sql-driver/mysql@v1.7.1",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/go-sql-driver/mysql@v1.7.1"
  ],
  "symbols": [
    "github.com/go-sql-driver/mysql.RegisterTLSConfig"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract_test.go
package test

import (
	"crypto/tls"
	"testing"

	"github.com/go-sql-driver/mysql"
)

func TestRegisterTLSConfig_CustomKey(t *testing.T) {
	tlsConfig := &tls.Config{
		MinVersion: tls.VersionTLS12,
	}
	key := "custom-test-tls"

	err := mysql.RegisterTLSConfig(key, tlsConfig)
	if err != nil {
		t.Fatalf("RegisterTLSConfig(%q) failed unexpectedly: %v", key, err)
	}
	defer mysql.DeregisterTLSConfig(key)

	cfg, err := mysql.ParseDSN("user:pass@tcp(127.0.0.1:3306)/dbname?tls=" + key)
	if err != nil {
		t.Fatalf("ParseDSN with registered TLS config failed: %v", err)
	}
	if cfg.TLSConfig != key {
		t.Fatalf("expected TLSConfig to be %q, got %q", key, cfg.TLSConfig)
	}
}

func TestRegisterTLSConfig_ReservedKeys(t *testing.T) {
	tlsConfig := &tls.Config{
		MinVersion: tls.VersionTLS12,
	}
	reservedKeys := []string{"true", "false", "skip-verify", "preferred"}

	for _, key := range reservedKeys {
		err := mysql.RegisterTLSConfig(key, tlsConfig)
		if err == nil {
			t.Errorf("RegisterTLSConfig(%q) expected error for reserved key, got nil", key)
			mysql.DeregisterTLSConfig(key)
		}
	}
}

func TestRegisterTLSConfig_Deregister(t *testing.T) {
	tlsConfig := &tls.Config{
		MinVersion: tls.VersionTLS12,
	}
	key := "temporary-tls"

	err := mysql.RegisterTLSConfig(key, tlsConfig)
	if err != nil {
		t.Fatalf("RegisterTLSConfig(%q) failed: %v", key, err)
	}

	mysql.DeregisterTLSConfig(key)
}

Origin Seeder

anonymous