Exemplo
github.com/miekg/dns v1.1.63: Msg.SetQuestion
Amostra verificada para golang github.com/miekg/dns v1.1.63: Msg.SetQuestion. O contrato rodou em go 1.26 · linux alpine/x64 · docker e passou.
sha256:5867770ff821250d5a48590b9959705c8898176d435beb424577b909166cbf1c
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 amd64 go 1.26 go 1
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-26 |
Caso
HOW- Objetivo
- verify dns.Msg.SetQuestion in pkg:golang/github.com/miekg/dns@v1.1.63
- Pacotes
- Símbolos
-
- dns.Msg.SetQuestion
- Criado
- 2026-08-26T04:48:32Z
Contrato
- dns.Msg.SetQuestion initializes Question section with single DNS question containing normalized FQDN and specified RR type
- dns.Msg.SetQuestion sets default query class to ClassINET for standard DNS queries
- dns.Msg.SetQuestion supports multiple DNS record types including TypeA, TypeAAAA, TypeTXT, and TypeMX
- dns.Msg.SetQuestion replaces existing questions when called repeatedly on the same message
Arquivos
- PROMPT.md
- csx.json
- dns_question.go
- go.mod
- go.sum
- spec.json
- test/contract_test.go
Código-fonte
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 dns.Msg.SetQuestion in pkg:golang/github.com/miekg/dns@v1.1.63
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/miekg/dns@v1.1.63
Demonstrate these symbols/APIs:
- dns.Msg.SetQuestion
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.
{"case":{"caseId":"case:sha256:8e95009363bc9d03ff2156a98f8ba20dd56c72b48be004a80424b8f55a293f1a","contract":["dns.Msg.SetQuestion initializes Question section with single DNS question containing normalized FQDN and specified RR type","dns.Msg.SetQuestion sets default query class to ClassINET for standard DNS queries","dns.Msg.SetQuestion supports multiple DNS record types including TypeA, TypeAAAA, TypeTXT, and TypeMX","dns.Msg.SetQuestion replaces existing questions when called repeatedly on the same message"],"goal":"verify dns.Msg.SetQuestion in pkg:golang/github.com/miekg/dns@v1.1.63","kind":"HOW","packages":["pkg:golang/github.com/miekg/dns@v1.1.63"],"schemaVersion":1,"symbols":["dns.Msg.SetQuestion"]},"contractCommand":["go","test","-v","./..."],"environment":{"arch":"amd64","compiler":"go","compilerVersion":"1.26.6","distro":"ubuntu","ecosystem":"golang","language":"go","languageVersion":"1.26.6","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/miekg/dns@v1.1.63"],"schemaVersion":1,"subject":"pkg:golang/github.com/miekg/dns@v1.1.63","symbols":["dns.Msg.SetQuestion"],"verifierAdapter":"golang@1"}
package dnsquestion
import (
"fmt"
"github.com/miekg/dns"
)
// NewDNSQuery creates a new DNS query message with question configured for domain and query type.
func NewDNSQuery(domain string, qtype uint16) *dns.Msg {
msg := new(dns.Msg)
msg.SetQuestion(dns.Fqdn(domain), qtype)
return msg
}
// ResetQuestion changes the question on an existing DNS message.
func ResetQuestion(msg *dns.Msg, domain string, qtype uint16) {
msg.SetQuestion(dns.Fqdn(domain), qtype)
}
// GetQuestionDetails returns the question name, query type, and query class.
func GetQuestionDetails(msg *dns.Msg) (string, uint16, uint16, error) {
if len(msg.Question) == 0 {
return "", 0, 0, fmt.Errorf("message has no questions")
}
q := msg.Question[0]
return q.Name, q.Qtype, q.Qclass, nil
}
module example.com/dnsquestion
go 1.26.6
require (
github.com/miekg/dns v1.1.63
golang.org/x/mod v0.18.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/tools v0.22.0 // indirect
)
github.com/miekg/dns v1.1.63 h1:8M5aAw6OMZfFXTT7K5V0Eu5YiiL8l7nUAkyN6C9YwaY=
github.com/miekg/dns v1.1.63/go.mod h1:6NGHfjhpmr5lt3XPLuyfDJi5AXbNIPM9PY6H6sF1Nfs=
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
{
"schemaVersion": 1,
"goal": "verify dns.Msg.SetQuestion in pkg:golang/github.com/miekg/dns@v1.1.63",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/miekg/dns@v1.1.63"
],
"symbols": [
"dns.Msg.SetQuestion"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
package test
import (
"testing"
"example.com/dnsquestion"
"github.com/miekg/dns"
)
func TestSetQuestionInitializesSingleQuestion(t *testing.T) {
domain := "example.com"
msg := dnsquestion.NewDNSQuery(domain, dns.TypeA)
if len(msg.Question) != 1 {
t.Fatalf("expected 1 question in msg.Question slice, got %d", len(msg.Question))
}
name, qtype, qclass, err := dnsquestion.GetQuestionDetails(msg)
if err != nil {
t.Fatalf("unexpected error getting question details: %v", err)
}
expectedFQDN := "example.com."
if name != expectedFQDN {
t.Errorf("expected question name %q, got %q", expectedFQDN, name)
}
if qtype != dns.TypeA {
t.Errorf("expected Qtype TypeA (%d), got %d", dns.TypeA, qtype)
}
if qclass != dns.ClassINET {
t.Errorf("expected Qclass ClassINET (%d), got %d", dns.ClassINET, qclass)
}
}
func TestSetQuestionSupportsVariousRecordTypes(t *testing.T) {
testCases := []struct {
domain string
qtype uint16
}{
{"example.org", dns.TypeAAAA},
{"mail.example.com", dns.TypeMX},
{"sub.example.net", dns.TypeTXT},
{"_sip._tcp.example.com", dns.TypeSRV},
}
for _, tc := range testCases {
msg := dnsquestion.NewDNSQuery(tc.domain, tc.qtype)
name, qtype, qclass, err := dnsquestion.GetQuestionDetails(msg)
if err != nil {
t.Fatalf("failed to get question for %s: %v", tc.domain, err)
}
expectedName := dns.Fqdn(tc.domain)
if name != expectedName {
t.Errorf("expected name %s, got %s", expectedName, name)
}
if qtype != tc.qtype {
t.Errorf("expected qtype %d, got %d", tc.qtype, qtype)
}
if qclass != dns.ClassINET {
t.Errorf("expected qclass ClassINET, got %d", qclass)
}
}
}
func TestSetQuestionReplacesExistingQuestion(t *testing.T) {
msg := dnsquestion.NewDNSQuery("first.example.com", dns.TypeA)
if len(msg.Question) != 1 || msg.Question[0].Name != "first.example.com." {
t.Fatalf("initial question setup failed")
}
dnsquestion.ResetQuestion(msg, "second.example.com", dns.TypeTXT)
if len(msg.Question) != 1 {
t.Fatalf("expected question list to have length 1 after reset, got %d", len(msg.Question))
}
if msg.Question[0].Name != "second.example.com." {
t.Errorf("expected replaced question name 'second.example.com.', got %q", msg.Question[0].Name)
}
if msg.Question[0].Qtype != dns.TypeTXT {
t.Errorf("expected replaced question type TypeTXT (%d), got %d", dns.TypeTXT, msg.Question[0].Qtype)
}
}
Seeder de origem
anônimo