CodeSampleX

Beispiel

golang.org/x/net v0.38.0: idna.Lookup

Verifiziertes Beispiel für golang golang.org/x/net v0.38.0: idna.Lookup. Der Vertrag lief auf go 1.26 · linux alpine/x64 · docker und bestand.

sha256:1700f866a5b3f765e4e152b7c54d6422e121db5286d35d7b9de0d0d601b839f5

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 linux 24 · ubuntu · glibc 2.39 x64 go

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-30

Fall

HOW
Ziel
verify golang.org/x/net/idna.Lookup in pkg:golang/golang.org/x/net@v0.38.0
Pakete
Symbole
  • golang.org/x/net/idna.Lookup
Erstellt
2026-08-30T15:01:33Z

Contract

  1. idna.Lookup.ToASCII converts internationalized domain names containing Unicode characters to Punycode ASCII format
  2. idna.Lookup.ToUnicode decodes Punycode ASCII domain names back to Unicode format
  3. idna.Lookup.ToASCII leaves standard ASCII domain names unchanged
  4. idna.Lookup.ToASCII returns an error for invalid domain names violating IDNA rules

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 golang.org/x/net/idna.Lookup in pkg:golang/golang.org/x/net@v0.38.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/net@v0.38.0
Demonstrate these symbols/APIs:
  - golang.org/x/net/idna.Lookup

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:a1bf6c6cabb99babf015e684e6a829dcb39097b4f2a84e30ed0c9696bce8368e","contract":["idna.Lookup.ToASCII converts internationalized domain names containing Unicode characters to Punycode ASCII format","idna.Lookup.ToUnicode decodes Punycode ASCII domain names back to Unicode format","idna.Lookup.ToASCII leaves standard ASCII domain names unchanged","idna.Lookup.ToASCII returns an error for invalid domain names violating IDNA rules"],"goal":"verify golang.org/x/net/idna.Lookup in pkg:golang/golang.org/x/net@v0.38.0","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.38.0"],"schemaVersion":1,"symbols":["golang.org/x/net/idna.Lookup"]},"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/golang.org/x/net@v0.38.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.38.0","symbols":["golang.org/x/net/idna.Lookup"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.6

require golang.org/x/net v0.38.0

require golang.org/x/text v0.23.0 // indirect
go.sum
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
main.go
package main

import (
	"fmt"
	"os"

	"golang.org/x/net/idna"
)

// DomainToASCII converts a Unicode internationalized domain name to ASCII (Punycode).
func DomainToASCII(domain string) (string, error) {
	return idna.Lookup.ToASCII(domain)
}

// DomainToUnicode converts an ASCII (Punycode) domain name back to Unicode representation.
func DomainToUnicode(asciiDomain string) (string, error) {
	return idna.Lookup.ToUnicode(asciiDomain)
}

func main() {
	unicodeDomain := "münchen.de"
	asciiDomain, err := DomainToASCII(unicodeDomain)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error converting %q to ASCII: %v\n", unicodeDomain, err)
		os.Exit(1)
	}
	fmt.Printf("Unicode: %s -> ASCII: %s\n", unicodeDomain, asciiDomain)

	decodedUnicode, err := DomainToUnicode(asciiDomain)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error converting %q to Unicode: %v\n", asciiDomain, err)
		os.Exit(1)
	}
	fmt.Printf("ASCII: %s -> Decoded Unicode: %s\n", asciiDomain, decodedUnicode)

	standardDomain := "example.com"
	asciiStd, err := DomainToASCII(standardDomain)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error converting standard domain: %v\n", err)
		os.Exit(1)
	}
	fmt.Printf("Standard domain unchanged: %s\n", asciiStd)
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify golang.org/x/net/idna.Lookup in pkg:golang/golang.org/x/net@v0.38.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/net@v0.38.0"
  ],
  "symbols": [
    "golang.org/x/net/idna.Lookup"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"golang.org/x/net/idna"
)

func main() {
	// Assertion 1: idna.Lookup.ToASCII converts internationalized domain names containing Unicode characters to Punycode ASCII format
	unicodeDomain := "münchen.de"
	expectedASCII := "xn--mnchen-3ya.de"
	asciiResult, err := idna.Lookup.ToASCII(unicodeDomain)
	if err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: ToASCII(%q) returned error: %v\n", unicodeDomain, err)
		os.Exit(1)
	}
	if asciiResult != expectedASCII {
		fmt.Fprintf(os.Stderr, "FAIL: ToASCII(%q) = %q, expected %q\n", unicodeDomain, asciiResult, expectedASCII)
		os.Exit(1)
	}

	// Assertion 2: idna.Lookup.ToUnicode decodes Punycode ASCII domain names back to Unicode format
	unicodeResult, err := idna.Lookup.ToUnicode(expectedASCII)
	if err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: ToUnicode(%q) returned error: %v\n", expectedASCII, err)
		os.Exit(1)
	}
	if unicodeResult != unicodeDomain {
		fmt.Fprintf(os.Stderr, "FAIL: ToUnicode(%q) = %q, expected %q\n", expectedASCII, unicodeResult, unicodeDomain)
		os.Exit(1)
	}

	// Assertion 3: idna.Lookup.ToASCII leaves standard ASCII domain names unchanged
	standardDomain := "example.com"
	stdResult, err := idna.Lookup.ToASCII(standardDomain)
	if err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: ToASCII(%q) returned error: %v\n", standardDomain, err)
		os.Exit(1)
	}
	if stdResult != standardDomain {
		fmt.Fprintf(os.Stderr, "FAIL: ToASCII(%q) = %q, expected %q\n", standardDomain, stdResult, standardDomain)
		os.Exit(1)
	}

	// Assertion 4: idna.Lookup.ToASCII returns an error for invalid domain names violating IDNA rules
	invalidDomain := "xn--invalid-punycode-%%%.example.com"
	if _, err := idna.Lookup.ToASCII(invalidDomain); err == nil {
		fmt.Fprintf(os.Stderr, "FAIL: ToASCII(%q) expected error, but got nil\n", invalidDomain)
		os.Exit(1)
	}

	fmt.Println("PASS: golang.org/x/net/idna.Lookup contract passed")
}

Ursprungs-Seeder

anonym