CodeSampleX

Exemplo

modernc.org/ccgo/v4 v4.34.6: lib.IsExecEnv

Amostra verificada para golang modernc.org/ccgo/v4 v4.34.6: lib.IsExecEnv. O contrato rodou em go 1.26 · linux debian/x64 · docker e passou.

sha256:08a6b53174d1e048099dec557509a0ba5eab31ca9c97c7175d1267f9d333bb0a

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

Caso

HOW
Objetivo
verify modernc.org/ccgo/v4/lib.IsExecEnv in pkg:golang/modernc.org/ccgo/v4@v4.34.6
Pacotes
Símbolos
  • modernc.org/ccgo/v4/lib.IsExecEnv
Criado
2026-09-16T10:13:19Z

Contrato

  1. ccgo.IsExecEnv returns false when the CCGO_EXEC_ENV environment variable is unset
  2. ccgo.IsExecEnv returns false when the CCGO_EXEC_ENV environment variable is empty
  3. ccgo.IsExecEnv returns true when the CCGO_EXEC_ENV environment variable is set to a non-empty string
  4. ccgo.IsExecEnv dynamically reflects changes to the CCGO_EXEC_ENV environment variable across invocations

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 modernc.org/ccgo/v4/lib.IsExecEnv in pkg:golang/modernc.org/ccgo/v4@v4.34.6
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/modernc.org/ccgo/v4@v4.34.6
Demonstrate these symbols/APIs:
  - modernc.org/ccgo/v4/lib.IsExecEnv

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:c6391c26aa03a22b2ef39ed7d7ce76011d6ab048beaa55f8851c6366ef122069","contract":["ccgo.IsExecEnv returns false when the CCGO_EXEC_ENV environment variable is unset","ccgo.IsExecEnv returns false when the CCGO_EXEC_ENV environment variable is empty","ccgo.IsExecEnv returns true when the CCGO_EXEC_ENV environment variable is set to a non-empty string","ccgo.IsExecEnv dynamically reflects changes to the CCGO_EXEC_ENV environment variable across invocations"],"goal":"verify modernc.org/ccgo/v4/lib.IsExecEnv in pkg:golang/modernc.org/ccgo/v4@v4.34.6","kind":"HOW","packages":["pkg:golang/modernc.org/ccgo/v4@v4.34.6"],"schemaVersion":1,"symbols":["modernc.org/ccgo/v4/lib.IsExecEnv"]},"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/modernc.org/ccgo/v4@v4.34.6"],"schemaVersion":1,"subject":"pkg:golang/modernc.org/ccgo/v4@v4.34.6","symbols":["modernc.org/ccgo/v4/lib.IsExecEnv"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.6

require modernc.org/ccgo/v4 v4.34.6

require (
	github.com/dustin/go-humanize v1.0.1 // indirect
	github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
	github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
	golang.org/x/mod v0.37.0 // indirect
	golang.org/x/sync v0.21.0 // indirect
	golang.org/x/tools v0.46.0 // indirect
	modernc.org/cc/v4 v4.29.0 // indirect
	modernc.org/gc/v2 v2.6.5 // indirect
	modernc.org/gc/v3 v3.1.4 // indirect
	modernc.org/mathutil v1.7.1 // indirect
	modernc.org/opt v0.2.0 // indirect
	modernc.org/sortutil v1.2.1 // indirect
	modernc.org/strutil v1.2.1 // indirect
	modernc.org/token v1.1.0 // indirect
)
go.sum
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0=
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2wtOnGAHZWCHUM4KGzY=
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ=
golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0=
golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/tools v0.46.0 h1:7jTurBkPZu4moS/Uy4OQT1M+QBlsj3wejyZwsT8Z7rk=
golang.org/x/tools v0.46.0/go.mod h1:FrD85F8l+NWL+9XWBSyVSHO6Ne4jutsfIFba7AWQ5Ys=
modernc.org/cc/v4 v4.29.0 h1:CXgwL8cvxmyzBQZzbSl/6xFtMCryb6u8IOqDci39cgc=
modernc.org/cc/v4 v4.29.0/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI=
modernc.org/ccgo/v4 v4.34.6 h1:sBgfIwyN0TQ9C5hwIeuqyeAKyMWnbvj2fvpF4L11uzU=
modernc.org/ccgo/v4 v4.34.6/go.mod h1:SZ8YcN9NG7XVsQYdm6jYBvi8PQP1qi+kqB6OhjqI3Fk=
modernc.org/ccorpus2 v1.6.0 h1:JODbahvmixwZDoF1kZs/9Rj6aHA2vAPP7HKiNDq//xo=
modernc.org/ccorpus2 v1.6.0/go.mod h1:Wifvo4Q/qS/h1aRoC2TffcHsnxwTikmi1AuLANuucJQ=
modernc.org/fileutil v1.4.0 h1:j6ZzNTftVS054gi281TyLjHPp6CPHr2KCxEXjEbD6SM=
modernc.org/fileutil v1.4.0/go.mod h1:EqdKFDxiByqxLk8ozOxObDSfcVOv/54xDs/DUHdvCUU=
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
modernc.org/gc/v3 v3.1.4 h1:2g65LGVSmFQrXeITAw97x7hCRvZFcyE1uDP+7Vng7JI=
modernc.org/gc/v3 v3.1.4/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
modernc.org/lex v1.1.1 h1:prSCNTLw1R4rn7M/RzwsuMtAuOytfyR3cnyM07P+Pas=
modernc.org/lex v1.1.1/go.mod h1:6r8o8DLJkAnOsQaGi8fMoi+Vt6LTbDaCrkUK729D8xM=
modernc.org/lexer v1.0.4 h1:hU7xVbZsqwPphyzChc7nMSGrsuaD2PDNOmzrzkS5AlE=
modernc.org/lexer v1.0.4/go.mod h1:tOajb8S4sdfOYitzCgXDFmbVJ/LE0v1fNJ7annTw36U=
modernc.org/libc v1.73.5 h1:G34rN/cRqL+zOUnrbz9uPq/+OxJ8/vzQ2CQwTJ42Wmw=
modernc.org/libc v1.73.5/go.mod h1:+Aoyx4M0etg6GikzCrip1VtvAtUlMlo2Aq+GHwQSqOA=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
modernc.org/opt v0.2.0 h1:tGyef5ApycA7FSEOMraay9SaTk5zmbx7Tu+cJs4QKZg=
modernc.org/opt v0.2.0/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
modernc.org/scannertest v1.0.2 h1:JPtfxcVdbRvzmRf2YUvsDibJsQRw8vKA/3jb31y7cy0=
modernc.org/scannertest v1.0.2/go.mod h1:RzTm5RwglF/6shsKoEivo8N91nQIoWtcWI7ns+zPyGA=
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
main.go
package main

import (
	"fmt"
	"os"

	"modernc.org/ccgo/v4/lib"
)

func main() {
	initial := ccgo.IsExecEnv()
	fmt.Printf("Initial ccgo.IsExecEnv(): %v\n", initial)

	_ = os.Setenv("CCGO_EXEC_ENV", "1")
	configured := ccgo.IsExecEnv()
	fmt.Printf("Configured ccgo.IsExecEnv(): %v\n", configured)

	_ = os.Unsetenv("CCGO_EXEC_ENV")
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify modernc.org/ccgo/v4/lib.IsExecEnv in pkg:golang/modernc.org/ccgo/v4@v4.34.6",
  "kind": "HOW",
  "packages": [
    "pkg:golang/modernc.org/ccgo/v4@v4.34.6"
  ],
  "symbols": [
    "modernc.org/ccgo/v4/lib.IsExecEnv"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"modernc.org/ccgo/v4/lib"
)

func main() {
	origVal, hadOrig := os.LookupEnv("CCGO_EXEC_ENV")
	defer func() {
		if hadOrig {
			_ = os.Setenv("CCGO_EXEC_ENV", origVal)
		} else {
			_ = os.Unsetenv("CCGO_EXEC_ENV")
		}
	}()

	// Assertion 1: ccgo.IsExecEnv returns false when the CCGO_EXEC_ENV environment variable is unset
	{
		if err := os.Unsetenv("CCGO_EXEC_ENV"); err != nil {
			fmt.Fprintf(os.Stderr, "Assertion 1 setup failed: %v\n", err)
			os.Exit(1)
		}
		if ccgo.IsExecEnv() {
			fmt.Fprintf(os.Stderr, "Assertion 1 failed: expected ccgo.IsExecEnv() to return false when unset\n")
			os.Exit(1)
		}
	}

	// Assertion 2: ccgo.IsExecEnv returns false when the CCGO_EXEC_ENV environment variable is empty
	{
		if err := os.Setenv("CCGO_EXEC_ENV", ""); err != nil {
			fmt.Fprintf(os.Stderr, "Assertion 2 setup failed: %v\n", err)
			os.Exit(1)
		}
		if ccgo.IsExecEnv() {
			fmt.Fprintf(os.Stderr, "Assertion 2 failed: expected ccgo.IsExecEnv() to return false when empty\n")
			os.Exit(1)
		}
	}

	// Assertion 3: ccgo.IsExecEnv returns true when the CCGO_EXEC_ENV environment variable is set to a non-empty string
	{
		testValues := []string{"1", "true", "enabled", "gcc,clang"}
		for _, val := range testValues {
			if err := os.Setenv("CCGO_EXEC_ENV", val); err != nil {
				fmt.Fprintf(os.Stderr, "Assertion 3 setup failed for %q: %v\n", val, err)
				os.Exit(1)
			}
			if !ccgo.IsExecEnv() {
				fmt.Fprintf(os.Stderr, "Assertion 3 failed: expected ccgo.IsExecEnv() to return true when set to %q\n", val)
				os.Exit(1)
			}
		}
	}

	// Assertion 4: ccgo.IsExecEnv dynamically reflects changes to the CCGO_EXEC_ENV environment variable across invocations
	{
		if err := os.Unsetenv("CCGO_EXEC_ENV"); err != nil {
			fmt.Fprintf(os.Stderr, "Assertion 4 setup failed: %v\n", err)
			os.Exit(1)
		}
		if ccgo.IsExecEnv() {
			fmt.Fprintf(os.Stderr, "Assertion 4 failed: expected false before setting\n")
			os.Exit(1)
		}

		if err := os.Setenv("CCGO_EXEC_ENV", "configured"); err != nil {
			fmt.Fprintf(os.Stderr, "Assertion 4 setup failed: %v\n", err)
			os.Exit(1)
		}
		if !ccgo.IsExecEnv() {
			fmt.Fprintf(os.Stderr, "Assertion 4 failed: expected true after setting\n")
			os.Exit(1)
		}

		if err := os.Unsetenv("CCGO_EXEC_ENV"); err != nil {
			fmt.Fprintf(os.Stderr, "Assertion 4 setup failed: %v\n", err)
			os.Exit(1)
		}
		if ccgo.IsExecEnv() {
			fmt.Fprintf(os.Stderr, "Assertion 4 failed: expected false after unsetting\n")
			os.Exit(1)
		}
	}

	fmt.Println("PASS: all ccgo.IsExecEnv contract assertions passed")
}

Seeder de origem

anônimo