CodeSampleX

샘플

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

검증된 샘플 — golang honnef.co/go/tools v0.0.1-2019.2.3. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: version.Version returns release version…

sha256:fc7314ed8a817c0b357d7109acd5228cb8b297b526ff14c53eb0741089764c9f

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 linux 24 · ubuntu · glibc 2.39 x64 go

검증 실행 환경

환경 컨트랙트 단계 실행일
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

케이스

HOW
목표
verify pkg:golang/honnef.co/go/tools@v0.0.1-2019.2.3
패키지
생성일
2026-09-15T22:17:06Z

컨트랙트

  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

파일

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • main.go
  • spec.json
  • test/contract.go

소스 아티팩트 내려받기 (tar.gz)

소스

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.")
}

오리진 시더

익명