CodeSampleX

Ejemplo

github.com/magiconair/properties v1.8.1: LoadString

Muestra verificada para golang github.com/magiconair/properties v1.8.1: LoadString. El contrato se ejecutó en go 1.26 · linux debian/x64 · docker y pasó.

sha256:2cdb72e5e3dd177618f18eaf80ffe287a14e523d3bee7aad532108edee2ae81d

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado linux 24 · ubuntu · glibc 2.39 x64 go

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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-29

Caso

HOW
Objetivo
verify LoadString in pkg:golang/github.com/magiconair/properties@v1.8.1
Paquetes
Símbolos
  • LoadString
Creado
2026-10-29T00:53:07Z

Contrato

  1. properties.LoadString parses UTF-8 key-value pairs and comments into a *properties.Properties instance with nil error
  2. properties.LoadString expands ${key} property references when retrieved via Get or GetString
  3. properties.LoadString returns an empty *properties.Properties (Len() == 0) with nil error for comment-only input
  4. properties.LoadString returns a non-nil error when input contains circular property references

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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 LoadString in pkg:golang/github.com/magiconair/properties@v1.8.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/magiconair/properties@v1.8.1
Demonstrate these symbols/APIs:
  - LoadString

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:57c4ffd60f184a5455b713ae00e1952a8377915fbce7e93551ff0563f375115f","contract":["properties.LoadString parses UTF-8 key-value pairs and comments into a *properties.Properties instance with nil error","properties.LoadString expands ${key} property references when retrieved via Get or GetString","properties.LoadString returns an empty *properties.Properties (Len() == 0) with nil error for comment-only input","properties.LoadString returns a non-nil error when input contains circular property references"],"goal":"verify LoadString in pkg:golang/github.com/magiconair/properties@v1.8.1","kind":"HOW","packages":["pkg:golang/github.com/magiconair/properties@v1.8.1"],"schemaVersion":1,"symbols":["LoadString"]},"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/github.com/magiconair/properties@v1.8.1"],"schemaVersion":1,"subject":"pkg:golang/github.com/magiconair/properties@v1.8.1","symbols":["LoadString"],"verifierAdapter":"golang@1"}
go.mod
module sample

go 1.26.6

require github.com/magiconair/properties v1.8.1
go.sum
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
main.go
package main

import (
	"fmt"
	"os"

	"github.com/magiconair/properties"
)

func main() {
	input := "host = localhost\nport = 8080\naddress = ${host}:${port}\n"
	p, err := properties.LoadString(input)
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	fmt.Println(p.GetString("address", ""))
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify LoadString in pkg:golang/github.com/magiconair/properties@v1.8.1",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/magiconair/properties@v1.8.1"
  ],
  "symbols": [
    "LoadString"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"github.com/magiconair/properties"
)

func main() {
	// 1. properties.LoadString parses UTF-8 key-value pairs and comments into a *properties.Properties instance
	raw := "# Server configuration\nhost = localhost\nport : 8080\nenabled = true\naddress = ${host}:${port}\n"
	p, err := properties.LoadString(raw)
	if err != nil {
		fmt.Fprintf(os.Stderr, "expected nil error from LoadString, got %v\n", err)
		os.Exit(1)
	}
	if p == nil {
		fmt.Fprintln(os.Stderr, "expected non-nil *properties.Properties")
		os.Exit(1)
	}
	if got := p.Len(); got != 4 {
		fmt.Fprintf(os.Stderr, "expected 4 properties, got %d\n", got)
		os.Exit(1)
	}
	if got, ok := p.Get("host"); !ok || got != "localhost" {
		fmt.Fprintf(os.Stderr, "expected host=\"localhost\" (ok=true), got %q (ok=%v)\n", got, ok)
		os.Exit(1)
	}
	if got := p.GetInt("port", 0); got != 8080 {
		fmt.Fprintf(os.Stderr, "expected port=8080, got %d\n", got)
		os.Exit(1)
	}
	if !p.GetBool("enabled", false) {
		fmt.Fprintln(os.Stderr, "expected enabled=true, got false")
		os.Exit(1)
	}

	// 2. properties.LoadString expands ${key} property references when retrieved via Get or GetString
	if got := p.GetString("address", ""); got != "localhost:8080" {
		fmt.Fprintf(os.Stderr, "expected expanded address \"localhost:8080\", got %q\n", got)
		os.Exit(1)
	}

	// 3. properties.LoadString returns an empty *properties.Properties with nil error for empty or comment-only input
	emptyProps, err := properties.LoadString("# comment only\n! another comment\n")
	if err != nil {
		fmt.Fprintf(os.Stderr, "expected nil error for comment-only input, got %v\n", err)
		os.Exit(1)
	}
	if emptyProps.Len() != 0 {
		fmt.Fprintf(os.Stderr, "expected 0 keys for comment-only input, got %d\n", emptyProps.Len())
		os.Exit(1)
	}

	// 4. properties.LoadString returns a non-nil error when input contains circular property references
	_, err = properties.LoadString("a = ${b}\nb = ${a}\n")
	if err == nil {
		fmt.Fprintln(os.Stderr, "expected non-nil error for circular property reference, got nil")
		os.Exit(1)
	}
}

Seeder de origen

anónimo