CodeSampleX

Exemplo

github.com/russross/blackfriday/v2 v2.1.0: SanitizedAnchorName

Amostra verificada para golang github.com/russross/blackfriday/v2 v2.1.0: SanitizedAnchorName. O contrato rodou em go 1.26 · linux alpine/x64 · docker e…

sha256:57000352f1c9b0460c7ea422462261e2f41d3dd499d9ebb9770cbd3c5e15c501

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado linux 24 · ubuntu · glibc 2.39 x64 go

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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-28

Caso

HOW
Objetivo
verify github.com/russross/blackfriday/v2.SanitizedAnchorName in pkg:golang/github.com/russross/blackfriday/v2@v2.1.0
Pacotes
Símbolos
  • github.com/russross/blackfriday/v2.SanitizedAnchorName
Criado
2026-08-28T00:28:02Z

Contrato

  1. blackfriday.SanitizedAnchorName converts text to lowercase hyphenated string
  2. blackfriday.SanitizedAnchorName strips punctuation, symbols and trims leading/trailing hyphens
  3. blackfriday.SanitizedAnchorName collapses consecutive whitespace and special characters into single hyphens
  4. blackfriday.SanitizedAnchorName returns empty string for empty or whitespace-only inputs

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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/russross/blackfriday/v2.SanitizedAnchorName in pkg:golang/github.com/russross/blackfriday/v2@v2.1.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/russross/blackfriday/v2@v2.1.0
Demonstrate these symbols/APIs:
  - github.com/russross/blackfriday/v2.SanitizedAnchorName

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:229ae45b58ffb6506313660456eeb8bef23fe3686e18f1e203ce282380198de8","contract":["blackfriday.SanitizedAnchorName converts text to lowercase hyphenated string","blackfriday.SanitizedAnchorName strips punctuation, symbols and trims leading/trailing hyphens","blackfriday.SanitizedAnchorName collapses consecutive whitespace and special characters into single hyphens","blackfriday.SanitizedAnchorName returns empty string for empty or whitespace-only inputs"],"goal":"verify github.com/russross/blackfriday/v2.SanitizedAnchorName in pkg:golang/github.com/russross/blackfriday/v2@v2.1.0","kind":"HOW","packages":["pkg:golang/github.com/russross/blackfriday/v2@v2.1.0"],"schemaVersion":1,"symbols":["github.com/russross/blackfriday/v2.SanitizedAnchorName"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/russross/blackfriday/v2@v2.1.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/russross/blackfriday/v2@v2.1.0","symbols":["github.com/russross/blackfriday/v2.SanitizedAnchorName"],"verifierAdapter":"golang@1"}
go.mod
module sample

go 1.21

require github.com/russross/blackfriday/v2 v2.1.0
go.sum
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
spec.json
{
  "schemaVersion": 1,
  "goal": "verify github.com/russross/blackfriday/v2.SanitizedAnchorName in pkg:golang/github.com/russross/blackfriday/v2@v2.1.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/russross/blackfriday/v2@v2.1.0"
  ],
  "symbols": [
    "github.com/russross/blackfriday/v2.SanitizedAnchorName"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"github.com/russross/blackfriday/v2"
)

func main() {
	if err := runContractTests(); err != nil {
		fmt.Fprintf(os.Stderr, "Contract test failed: %v\n", err)
		os.Exit(1)
	}
	fmt.Println("All contract tests passed.")
}

func runContractTests() error {
	// 1. SanitizedAnchorName converts text to lowercase hyphenated string
	in1 := "Hello World"
	exp1 := "hello-world"
	if got := blackfriday.SanitizedAnchorName(in1); got != exp1 {
		return fmt.Errorf("expected SanitizedAnchorName(%q) = %q, got %q", in1, exp1, got)
	}

	// 2. SanitizedAnchorName strips punctuation, symbols and trims leading/trailing hyphens
	in2 := "Chapter 1: Quick-Start & Overview! (#1)"
	exp2 := "chapter-1-quick-start-overview-1"
	if got := blackfriday.SanitizedAnchorName(in2); got != exp2 {
		return fmt.Errorf("expected SanitizedAnchorName(%q) = %q, got %q", in2, exp2, got)
	}

	// 3. SanitizedAnchorName collapses consecutive whitespace and special characters into single hyphens
	in3 := "Foo   ---   Bar ??? Baz"
	exp3 := "foo-bar-baz"
	if got := blackfriday.SanitizedAnchorName(in3); got != exp3 {
		return fmt.Errorf("expected SanitizedAnchorName(%q) = %q, got %q", in3, exp3, got)
	}

	// 4. SanitizedAnchorName returns empty string for empty or whitespace-only inputs
	if got := blackfriday.SanitizedAnchorName(""); got != "" {
		return fmt.Errorf("expected empty string for \"\", got %q", got)
	}
	if got := blackfriday.SanitizedAnchorName("   \t\n  "); got != "" {
		return fmt.Errorf("expected empty string for whitespace, got %q", got)
	}

	return nil
}

Seeder de origem

anônimo