CodeSampleX

Exemplo

honnef.co/go/tools v0.0.1-2019.2.3

Amostra verificada para golang honnef.co/go/tools v0.0.1-2019.2.3. O contrato rodou em go 1.26 · linux debian/x64 · docker e passou.

sha256:fc7314ed8a817c0b357d7109acd5228cb8b297b526ff14c53eb0741089764c9f

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 debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a…
2026-09-15

Caso

HOW
Objetivo
verify pkg:golang/honnef.co/go/tools@v0.0.1-2019.2.3
Pacotes
Criado
2026-09-15T22:17:06Z

Contrato

  1. version.Version returns release version string 2019.2.3
  2. arg.Arg returns 0-based argument position for standard library functions
  3. arg.Arg panics on unknown function argument query
  4. gcsizes.ForArch returns types.Sizes implementation for target architecture
  5. gcsizes.Sizes computes correct sizes and alignments for basic types

Arquivos

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • main.go
  • 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 pkg:golang/honnef.co/go/tools@v0.0.1-2019.2.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/honnef.co/go/tools@v0.0.1-2019.2.3

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:6437de5ec83bbe1eb36a14b1a7fd55fb04b21a76bc4bf9704cf9ca02df5acf81","contract":["version.Version returns release version string 2019.2.3","arg.Arg returns 0-based argument position for standard library functions","arg.Arg panics on unknown function argument query","gcsizes.ForArch returns types.Sizes implementation for target architecture","gcsizes.Sizes computes correct sizes and alignments for basic types"],"goal":"verify pkg:golang/honnef.co/go/tools@v0.0.1-2019.2.3","kind":"HOW","packages":["pkg:golang/honnef.co/go/tools@v0.0.1-2019.2.3"],"schemaVersion":1},"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/honnef.co/go/tools@v0.0.1-2019.2.3"],"schemaVersion":1,"subject":"pkg:golang/honnef.co/go/tools@v0.0.1-2019.2.3","verifierAdapter":"golang@1"}
go.mod
module sample

go 1.26.6

require honnef.co/go/tools v0.0.1-2019.2.3
go.sum
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
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/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
main.go
package main

import (
	"fmt"
	"go/types"

	"honnef.co/go/tools/arg"
	"honnef.co/go/tools/gcsizes"
	"honnef.co/go/tools/version"
)

func main() {
	fmt.Printf("honnef.co/go/tools version: %s\n", version.Version)

	query := "fmt.Fprintf.format"
	fmt.Printf("arg position for %s: %d\n", query, arg.Arg(query))

	sizes := gcsizes.ForArch("amd64")
	fmt.Printf("Word size: %d, int64 size: %d\n", sizes.WordSize, sizes.Sizeof(types.Typ[types.Int64]))
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:golang/honnef.co/go/tools@v0.0.1-2019.2.3",
  "kind": "HOW",
  "packages": [
    "pkg:golang/honnef.co/go/tools@v0.0.1-2019.2.3"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"go/types"
	"os"

	"honnef.co/go/tools/arg"
	"honnef.co/go/tools/gcsizes"
	"honnef.co/go/tools/version"
)

func main() {
	// Assertion 1: version.Version returns the expected release version string "2019.2.3"
	if version.Version != "2019.2.3" {
		fmt.Fprintf(os.Stderr, "expected version 2019.2.3, got %q\n", version.Version)
		os.Exit(1)
	}

	// Assertion 2: arg.Arg returns the expected 0-based argument position for standard library functions
	argCases := []struct {
		fn       string
		expected int
	}{
		{"fmt.Printf.format", 0},
		{"fmt.Fprintf.format", 1},
		{"fmt.Sprintf.format", 0},
		{"fmt.Sprintf.a[0]", 1},
		{"errors.New.text", 0},
		{"bytes.Equal.a", 0},
		{"bytes.Equal.b", 1},
		{"encoding/binary.Write.data", 2},
		{"json.Marshal.v", 0},
		{"json.Unmarshal.v", 1},
		{"time.Sleep.d", 0},
	}

	for _, tc := range argCases {
		got := arg.Arg(tc.fn)
		if got != tc.expected {
			fmt.Fprintf(os.Stderr, "arg.Arg(%q) = %d; want %d\n", tc.fn, got, tc.expected)
			os.Exit(1)
		}
	}

	// Assertion 3: arg.Arg panics when queried with an unknown argument key
	var panicked bool
	func() {
		defer func() {
			if r := recover(); r != nil {
				panicked = true
			}
		}()
		arg.Arg("nonexistent.Function.argument")
	}()

	if !panicked {
		fmt.Fprintf(os.Stderr, "expected arg.Arg to panic on unknown query, but it did not\n")
		os.Exit(1)
	}

	// Assertion 4: gcsizes.ForArch returns a types.Sizes implementation with architecture word size and alignment
	sizes := gcsizes.ForArch("amd64")
	if sizes == nil {
		fmt.Fprintf(os.Stderr, "gcsizes.ForArch returned nil\n")
		os.Exit(1)
	}
	var _ types.Sizes = sizes

	if sizes.WordSize <= 0 || sizes.MaxAlign <= 0 {
		fmt.Fprintf(os.Stderr, "invalid WordSize (%d) or MaxAlign (%d)\n", sizes.WordSize, sizes.MaxAlign)
		os.Exit(1)
	}

	// Assertion 5: gcsizes.Sizes computes correct sizes and alignments for basic types
	if sz := sizes.Sizeof(types.Typ[types.Int64]); sz != 8 {
		fmt.Fprintf(os.Stderr, "expected int64 size 8, got %d\n", sz)
		os.Exit(1)
	}
	if sz := sizes.Sizeof(types.Typ[types.Bool]); sz != 1 {
		fmt.Fprintf(os.Stderr, "expected bool size 1, got %d\n", sz)
		os.Exit(1)
	}
	if sz := sizes.Sizeof(types.Typ[types.String]); sz != sizes.WordSize*2 {
		fmt.Fprintf(os.Stderr, "expected string size %d, got %d\n", sizes.WordSize*2, sz)
		os.Exit(1)
	}
	if al := sizes.Alignof(types.Typ[types.Int64]); al != sizes.MaxAlign && al != 8 {
		fmt.Fprintf(os.Stderr, "unexpected int64 align %d\n", al)
		os.Exit(1)
	}

	fmt.Println("All contract assertions passed.")
}

Seeder de origem

anônimo