Пример
github.com/subosito/gotenv v1.2.0: Apply
Проверенный пример — golang github.com/subosito/gotenv v1.2.0: Apply. Контракт выполнен на go 1.26 · linux debian/x64 · docker и пройден.
sha256:3b6010732fc7f1a5d830a50c079252ff15e977ec89ecac5ff369b4a717f75893
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
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-10-29 |
Кейс
HOW- Цель
- verify github.com/subosito/gotenv.Apply in pkg:golang/github.com/subosito/gotenv@v1.2.0
- Символы
-
- github.com/subosito/gotenv.Apply
- Создан
- 2026-10-29T07:15:50Z
Контракт
- gotenv.Apply parses key-value pairs from an io.Reader and sets unset environment variables
- gotenv.Apply preserves already-set environment variables without overwriting them
- gotenv.Apply ignores blank lines and hash comment lines
- gotenv.Apply supports export prefix and double-quoted values containing spaces
Файлы
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Исходный код
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 github.com/subosito/gotenv.Apply in pkg:golang/github.com/subosito/gotenv@v1.2.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/subosito/gotenv@v1.2.0
Demonstrate these symbols/APIs:
- github.com/subosito/gotenv.Apply
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:a969576cbd83347465825ab31c4a89bf53aaabc4e842919635339b180bc45af4","contract":["gotenv.Apply parses key-value pairs from an io.Reader and sets unset environment variables","gotenv.Apply preserves already-set environment variables without overwriting them","gotenv.Apply ignores blank lines and hash comment lines","gotenv.Apply supports export prefix and double-quoted values containing spaces"],"goal":"verify github.com/subosito/gotenv.Apply in pkg:golang/github.com/subosito/gotenv@v1.2.0","kind":"HOW","packages":["pkg:golang/github.com/subosito/gotenv@v1.2.0"],"schemaVersion":1,"symbols":["github.com/subosito/gotenv.Apply"]},"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/subosito/gotenv@v1.2.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/subosito/gotenv@v1.2.0","symbols":["github.com/subosito/gotenv.Apply"],"verifierAdapter":"golang@1"}
module sample
go 1.21
require github.com/subosito/gotenv v1.2.0
require github.com/stretchr/testify v1.12.1 // indirect
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
package main
import (
"fmt"
"os"
"strings"
"github.com/subosito/gotenv"
)
func main() {
input := "APP_MODE=production\nAPP_PORT=8080\n"
if err := gotenv.Apply(strings.NewReader(input)); err != nil {
fmt.Fprintf(os.Stderr, "gotenv.Apply failed: %v\n", err)
os.Exit(1)
}
fmt.Printf("APP_MODE=%s APP_PORT=%s\n", os.Getenv("APP_MODE"), os.Getenv("APP_PORT"))
}
{
"schemaVersion": 1,
"goal": "verify github.com/subosito/gotenv.Apply in pkg:golang/github.com/subosito/gotenv@v1.2.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/subosito/gotenv@v1.2.0"
],
"symbols": [
"github.com/subosito/gotenv.Apply"
]
}
package main
import (
"fmt"
"os"
"strings"
"github.com/subosito/gotenv"
)
func main() {
// Assertion 1: gotenv.Apply parses key-value pairs from an io.Reader and sets unset environment variables
{
key := "CSX_GOTENV_UNSET_VAR"
expected := "alpha_val"
os.Unsetenv(key)
err := gotenv.Apply(strings.NewReader(fmt.Sprintf("%s=%s\n", key, expected)))
if err != nil {
fmt.Fprintf(os.Stderr, "Assertion 1 failed: unexpected error: %v\n", err)
os.Exit(1)
}
if got := os.Getenv(key); got != expected {
fmt.Fprintf(os.Stderr, "Assertion 1 failed: expected %q, got %q\n", expected, got)
os.Exit(1)
}
}
// Assertion 2: gotenv.Apply preserves already-set environment variables without overwriting them
{
key := "CSX_GOTENV_EXISTING_VAR"
initial := "original_val"
os.Setenv(key, initial)
err := gotenv.Apply(strings.NewReader(fmt.Sprintf("%s=replacement_val\n", key)))
if err != nil {
fmt.Fprintf(os.Stderr, "Assertion 2 failed: unexpected error: %v\n", err)
os.Exit(1)
}
if got := os.Getenv(key); got != initial {
fmt.Fprintf(os.Stderr, "Assertion 2 failed: expected %q, got %q\n", initial, got)
os.Exit(1)
}
}
// Assertion 3: gotenv.Apply ignores blank lines and hash comment lines
{
key := "CSX_GOTENV_ACTIVE_VAR"
commentKey := "CSX_GOTENV_COMMENT_VAR"
expected := "active_val"
os.Unsetenv(key)
os.Unsetenv(commentKey)
input := fmt.Sprintf("\n# %s=ignored\n%s=%s\n", commentKey, key, expected)
if err := gotenv.Apply(strings.NewReader(input)); err != nil {
fmt.Fprintf(os.Stderr, "Assertion 3 failed: unexpected error: %v\n", err)
os.Exit(1)
}
if got := os.Getenv(key); got != expected {
fmt.Fprintf(os.Stderr, "Assertion 3 failed: expected %q, got %q\n", expected, got)
os.Exit(1)
}
if got := os.Getenv(commentKey); got != "" {
fmt.Fprintf(os.Stderr, "Assertion 3 failed: expected comment variable to remain unset, got %q\n", got)
os.Exit(1)
}
}
// Assertion 4: gotenv.Apply supports export prefix and double-quoted values containing spaces
{
key := "CSX_GOTENV_QUOTED_VAR"
expected := "hello world value"
os.Unsetenv(key)
input := fmt.Sprintf("export %s=%q\n", key, expected)
if err := gotenv.Apply(strings.NewReader(input)); err != nil {
fmt.Fprintf(os.Stderr, "Assertion 4 failed: unexpected error: %v\n", err)
os.Exit(1)
}
if got := os.Getenv(key); got != expected {
fmt.Fprintf(os.Stderr, "Assertion 4 failed: expected %q, got %q\n", expected, got)
os.Exit(1)
}
}
fmt.Println("PASS")
}
Исходный сидер
аноним