Пример
golang.org/x/net v0.0.0-20200707034311-ab3426394381: httpproxy.Config, httpproxy.FromEnvironment
Проверенный пример — golang golang.org/x/net v0.0.0-20200707034311-ab3426394381: httpproxy.Config, httpproxy.FromEnvironment. Контракт выполнен на go 1.26 …
sha256:855bb7b6df814f8f58a62bbf3fbc7d0bd0f0c4634373c71a6c54650f8e55e912
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 2
- Ключи подписи, собравшие его
- 1
Заявленная среда
linux 24 · ubuntu · glibc 2.39 x64 go
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | SKIPPED | compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-10-13 |
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-10-13 |
Кейс
HOW- Цель
- verify pkg:golang/golang.org/x/net@v0.0.0-20200707034311-ab3426394381
- Символы
-
- golang.org/x/net/http/httpproxy.Config
- golang.org/x/net/http/httpproxy.FromEnvironment
- Создан
- 2026-10-13T06:07:31Z
Контракт
- httpproxy.Config.ProxyFunc routes HTTP and HTTPS URLs to configured proxy endpoints while bypassing destinations matching NoProxy patterns
- httpproxy.FromEnvironment initializes proxy configuration from HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables
Файлы
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Исходный код
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 pkg:golang/golang.org/x/net@v0.0.0-20200707034311-ab3426394381
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/net@v0.0.0-20200707034311-ab3426394381
Demonstrate these symbols/APIs:
- golang.org/x/net/http/httpproxy.Config
- golang.org/x/net/http/httpproxy.FromEnvironment
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.
{"case":{"caseId":"case:sha256:bf010aa2360c1ca575e26a51d36d422c2fc74fa6dfa2c835fa3d55e221122063","contract":["httpproxy.Config.ProxyFunc routes HTTP and HTTPS URLs to configured proxy endpoints while bypassing destinations matching NoProxy patterns","httpproxy.FromEnvironment initializes proxy configuration from HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables"],"goal":"verify pkg:golang/golang.org/x/net@v0.0.0-20200707034311-ab3426394381","kind":"HOW","packages":["pkg:golang/golang.org/x/net@v0.0.0-20200707034311-ab3426394381"],"schemaVersion":1,"symbols":["golang.org/x/net/http/httpproxy.Config","golang.org/x/net/http/httpproxy.FromEnvironment"]},"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.0.0-20200707034311-ab3426394381"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/net@v0.0.0-20200707034311-ab3426394381","symbols":["golang.org/x/net/http/httpproxy.Config","golang.org/x/net/http/httpproxy.FromEnvironment"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require golang.org/x/net v0.0.0-20200707034311-ab3426394381
require golang.org/x/text v0.3.0 // indirect
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU=
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
package main
import (
"fmt"
"log"
"net/url"
"golang.org/x/net/http/httpproxy"
)
func main() {
cfg := &httpproxy.Config{
HTTPProxy: "http://proxy.example.com:8080",
HTTPSProxy: "https://secure-proxy.example.com:8443",
NoProxy: "localhost,127.0.0.1,.internal.example.com",
}
proxyFunc := cfg.ProxyFunc()
targetURL, err := url.Parse("http://api.example.com/data")
if err != nil {
log.Fatalf("failed to parse url: %v", err)
}
proxyURL, err := proxyFunc(targetURL)
if err != nil {
log.Fatalf("failed to determine proxy: %v", err)
}
if proxyURL != nil {
fmt.Printf("Routing %s via proxy: %s\n", targetURL, proxyURL)
} else {
fmt.Printf("Routing %s directly (no proxy)\n", targetURL)
}
envCfg := httpproxy.FromEnvironment()
fmt.Printf("Environment proxy configured: HTTP=%q, HTTPS=%q, NO_PROXY=%q\n",
envCfg.HTTPProxy, envCfg.HTTPSProxy, envCfg.NoProxy)
fmt.Println("golang.org/x/net/http/httpproxy sample completed successfully")
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/golang.org/x/net@v0.0.0-20200707034311-ab3426394381",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/net@v0.0.0-20200707034311-ab3426394381"
],
"symbols": [
"golang.org/x/net/http/httpproxy.Config",
"golang.org/x/net/http/httpproxy.FromEnvironment"
]
}
package main
import (
"fmt"
"net/url"
"os"
"golang.org/x/net/http/httpproxy"
)
func main() {
// Assertion 1: httpproxy.Config.ProxyFunc routes HTTP and HTTPS URLs to configured proxy endpoints while bypassing destinations matching NoProxy patterns
{
cfg := &httpproxy.Config{
HTTPProxy: "http://proxy.example.com:8080",
HTTPSProxy: "https://secure-proxy.example.com:8443",
NoProxy: "localhost,127.0.0.1,.internal.example.com,bypass.example.org",
}
proxyFunc := cfg.ProxyFunc()
testCases := []struct {
rawURL string
wantProxy string
shouldSkip bool
}{
{"http://api.example.com/items", "http://proxy.example.com:8080", false},
{"https://secure.example.com/items", "https://secure-proxy.example.com:8443", false},
{"http://service.internal.example.com/health", "", true},
{"https://bypass.example.org/status", "", true},
{"http://localhost:8080/test", "", true},
{"http://127.0.0.1:9090/metrics", "", true},
}
for _, tc := range testCases {
reqURL, err := url.Parse(tc.rawURL)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 1 failed: could not parse url %s: %v\n", tc.rawURL, err)
os.Exit(1)
}
proxyURL, err := proxyFunc(reqURL)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 1 failed: proxyFunc error for %s: %v\n", tc.rawURL, err)
os.Exit(1)
}
if tc.shouldSkip {
if proxyURL != nil {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected no proxy for %s, got %s\n", tc.rawURL, proxyURL.String())
os.Exit(1)
}
} else {
if proxyURL == nil {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected proxy %s for %s, got nil\n", tc.wantProxy, tc.rawURL)
os.Exit(1)
}
if proxyURL.String() != tc.wantProxy {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected proxy %s for %s, got %s\n", tc.wantProxy, tc.rawURL, proxyURL.String())
os.Exit(1)
}
}
}
}
// Assertion 2: httpproxy.FromEnvironment initializes proxy configuration from HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables
{
os.Setenv("HTTP_PROXY", "http://env-proxy.example.com:3128")
os.Setenv("HTTPS_PROXY", "https://env-secure.example.com:3129")
os.Setenv("NO_PROXY", "local.example.com")
defer func() {
os.Unsetenv("HTTP_PROXY")
os.Unsetenv("HTTPS_PROXY")
os.Unsetenv("NO_PROXY")
}()
envCfg := httpproxy.FromEnvironment()
if envCfg.HTTPProxy != "http://env-proxy.example.com:3128" {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected HTTPProxy %q, got %q\n", "http://env-proxy.example.com:3128", envCfg.HTTPProxy)
os.Exit(1)
}
if envCfg.HTTPSProxy != "https://env-secure.example.com:3129" {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected HTTPSProxy %q, got %q\n", "https://env-secure.example.com:3129", envCfg.HTTPSProxy)
os.Exit(1)
}
if envCfg.NoProxy != "local.example.com" {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected NoProxy %q, got %q\n", "local.example.com", envCfg.NoProxy)
os.Exit(1)
}
proxyFunc := envCfg.ProxyFunc()
uBypass, err := url.Parse("http://local.example.com/api")
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: url parse error: %v\n", err)
os.Exit(1)
}
pBypass, err := proxyFunc(uBypass)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: env proxyFunc error: %v\n", err)
os.Exit(1)
}
if pBypass != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected bypass for local.example.com, got %s\n", pBypass.String())
os.Exit(1)
}
uProxy, err := url.Parse("http://external.example.com/api")
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: url parse error: %v\n", err)
os.Exit(1)
}
pProxy, err := proxyFunc(uProxy)
if err != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: env proxyFunc error: %v\n", err)
os.Exit(1)
}
if pProxy == nil || pProxy.String() != "http://env-proxy.example.com:3128" {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected proxy %q, got %v\n", "http://env-proxy.example.com:3128", pProxy)
os.Exit(1)
}
}
fmt.Println("All contract assertions passed.")
}
Исходный сидер
аноним