CodeSampleX

Beispiel

golang.org/x/net v0.56.0: publicsuffix.EffectiveTLDPlusOne, publicsuffix.List, publicsuffix.PublicSuffix

Verifiziertes Beispiel für golang golang.org/x/net v0.56.0: publicsuffix.EffectiveTLDPlusOne, publicsuffix.List, publicsuffix.PublicSuffix. Der Vertrag lief…

sha256:d7a0a978d74728daebb32cef6c0c7d1c0e45bbcca136d000bdf6cf3559fd7014

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

Fall

HOW
Ziel
verify golang.org/x/net/publicsuffix in pkg:golang/golang.org/x/net@v0.56.0
Pakete
Symbole
  • publicsuffix.EffectiveTLDPlusOne
  • publicsuffix.List
  • publicsuffix.PublicSuffix
Erstellt
2026-08-28T09:25:53Z

Contract

  1. publicsuffix.PublicSuffix returns the public suffix and indicates whether it is managed by ICANN
  2. publicsuffix.EffectiveTLDPlusOne extracts the effective top-level domain plus one label
  3. publicsuffix.EffectiveTLDPlusOne returns an error for a bare public suffix without a preceding label
  4. publicsuffix.List implements cookiejar.PublicSuffixList to query public suffixes and describe its data source

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

Use EXACTLY these public packages and versions:
  - pkg:golang/golang.org/x/net@v0.56.0
Demonstrate these symbols/APIs:
  - publicsuffix.EffectiveTLDPlusOne
  - publicsuffix.List
  - publicsuffix.PublicSuffix

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:98c980a585b81fe8b62e68742bff1c72ee39862363090c8471acc8e11aee8c56","contract":["publicsuffix.PublicSuffix returns the public suffix and indicates whether it is managed by ICANN","publicsuffix.EffectiveTLDPlusOne extracts the effective top-level domain plus one label","publicsuffix.EffectiveTLDPlusOne returns an error for a bare public suffix without a preceding label","publicsuffix.List implements cookiejar.PublicSuffixList to query public suffixes and describe its data source"],"goal":"verify golang.org/x/net/publicsuffix in pkg:golang/golang.org/x/net@v0.56.0","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.56.0"],"schemaVersion":1,"symbols":["publicsuffix.EffectiveTLDPlusOne","publicsuffix.List","publicsuffix.PublicSuffix"]},"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.56.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.56.0","symbols":["publicsuffix.EffectiveTLDPlusOne","publicsuffix.List","publicsuffix.PublicSuffix"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.25.0

require golang.org/x/net v0.56.0
go.sum
golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o=
golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec=
main.go
package main

import (
	"fmt"
	"net/http/cookiejar"
	"os"

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

// ExtractRootDomain returns the effective top-level domain plus one label (eTLD+1).
func ExtractRootDomain(domain string) (string, error) {
	return publicsuffix.EffectiveTLDPlusOne(domain)
}

// GetPublicSuffix returns the public suffix and whether it is an ICANN suffix.
func GetPublicSuffix(domain string) (string, bool) {
	return publicsuffix.PublicSuffix(domain)
}

// GetSuffixFromList uses a cookiejar.PublicSuffixList to find the suffix.
func GetSuffixFromList(list cookiejar.PublicSuffixList, domain string) string {
	return list.PublicSuffix(domain)
}

func main() {
	domain := "sub.example.com"

	suffix, icann := GetPublicSuffix(domain)
	fmt.Printf("Domain: %s -> Suffix: %s (ICANN: %v)\n", domain, suffix, icann)

	root, err := ExtractRootDomain(domain)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error extracting root domain: %v\n", err)
		os.Exit(1)
	}
	fmt.Printf("Domain: %s -> Root Domain (eTLD+1): %s\n", domain, root)

	listSuffix := GetSuffixFromList(publicsuffix.List, domain)
	fmt.Printf("Domain: %s -> List Suffix: %s (%s)\n", domain, listSuffix, publicsuffix.List.String())
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify golang.org/x/net/publicsuffix in pkg:golang/golang.org/x/net@v0.56.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/golang.org/x/net@v0.56.0"
  ],
  "symbols": [
    "publicsuffix.EffectiveTLDPlusOne",
    "publicsuffix.List",
    "publicsuffix.PublicSuffix"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"net/http/cookiejar"
	"os"

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

func main() {
	// Assertion 1: publicsuffix.PublicSuffix returns the public suffix and indicates whether it is managed by ICANN
	suffix, icann := publicsuffix.PublicSuffix("www.example.com")
	if suffix != "com" || !icann {
		fmt.Fprintf(os.Stderr, "FAIL: expected 'com', icann=true; got %q, icann=%v\n", suffix, icann)
		os.Exit(1)
	}

	suffixUK, icannUK := publicsuffix.PublicSuffix("foo.co.uk")
	if suffixUK != "co.uk" || !icannUK {
		fmt.Fprintf(os.Stderr, "FAIL: expected 'co.uk', icann=true; got %q, icann=%v\n", suffixUK, icannUK)
		os.Exit(1)
	}

	// Assertion 2: publicsuffix.EffectiveTLDPlusOne extracts the effective top-level domain plus one label
	etld1, err := publicsuffix.EffectiveTLDPlusOne("sub.example.com")
	if err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: unexpected error for sub.example.com: %v\n", err)
		os.Exit(1)
	}
	if etld1 != "example.com" {
		fmt.Fprintf(os.Stderr, "FAIL: expected 'example.com', got %q\n", etld1)
		os.Exit(1)
	}

	etld2, err := publicsuffix.EffectiveTLDPlusOne("a.b.foo.co.uk")
	if err != nil {
		fmt.Fprintf(os.Stderr, "FAIL: unexpected error for a.b.foo.co.uk: %v\n", err)
		os.Exit(1)
	}
	if etld2 != "foo.co.uk" {
		fmt.Fprintf(os.Stderr, "FAIL: expected 'foo.co.uk', got %q\n", etld2)
		os.Exit(1)
	}

	// Assertion 3: publicsuffix.EffectiveTLDPlusOne returns an error for a bare public suffix without a preceding label
	_, err = publicsuffix.EffectiveTLDPlusOne("com")
	if err == nil {
		fmt.Fprintf(os.Stderr, "FAIL: expected error for bare TLD 'com', got nil\n")
		os.Exit(1)
	}

	_, err = publicsuffix.EffectiveTLDPlusOne("co.uk")
	if err == nil {
		fmt.Fprintf(os.Stderr, "FAIL: expected error for bare TLD 'co.uk', got nil\n")
		os.Exit(1)
	}

	// Assertion 4: publicsuffix.List implements cookiejar.PublicSuffixList to query public suffixes and describe its data source
	var list cookiejar.PublicSuffixList = publicsuffix.List
	listSuffix := list.PublicSuffix("blog.example.com")
	if listSuffix != "com" {
		fmt.Fprintf(os.Stderr, "FAIL: expected list suffix 'com', got %q\n", listSuffix)
		os.Exit(1)
	}
	if list.String() == "" {
		fmt.Fprintf(os.Stderr, "FAIL: expected non-empty description from List.String()\n")
		os.Exit(1)
	}

	fmt.Println("PASS: golang.org/x/net/publicsuffix contract verified")
}

Ursprungs-Seeder

anonym