示例
github.com/Masterminds/semver/v3 v3.2.0: semver.IncMinor
已验证示例 — golang github.com/Masterminds/semver/v3 v3.2.0: semver.IncMinor. contract 在 go 1.26 · linux debian/x64 · docker 上运行并通过.
sha256:aa865ac4ffc818433f8266eb13226b998afbc14980c7bf3cee87ae7b45d8c2dd
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go 1
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| 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-01 |
案例
HOW- 目标
- verify semver.IncMinor in pkg:golang/github.com/Masterminds/semver/v3@v3.2.0
- 符号
-
- semver.IncMinor
- 环境
- go 1.26.6
- 创建时间
- 2026-09-01T01:28:32Z
契约
- semver.Version.IncMinor increments the minor version by 1 and resets the patch version to 0
- semver.Version.IncMinor clears prerelease identifiers and build metadata from the resulting version
- semver.Version.IncMinor returns a new Version value without mutating the original Version instance
文件
- PROMPT.md
- csx.json
- go.mod
- go.sum
- sample.go
- spec.json
- test/contract_test.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 semver.IncMinor in pkg:golang/github.com/Masterminds/semver/v3@v3.2.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/Masterminds/semver/v3@v3.2.0
Demonstrate these symbols/APIs:
- semver.IncMinor
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:c8d94be4a2ae01b31c4e17ca7968c0a599a15ef3ad92dd97e6e389f6092c0437","contract":["semver.Version.IncMinor increments the minor version by 1 and resets the patch version to 0","semver.Version.IncMinor clears prerelease identifiers and build metadata from the resulting version","semver.Version.IncMinor returns a new Version value without mutating the original Version instance"],"goal":"verify semver.IncMinor in pkg:golang/github.com/Masterminds/semver/v3@v3.2.0","kind":"HOW","packages":["pkg:golang/github.com/Masterminds/semver/v3@v3.2.0"],"schemaVersion":1,"symbols":["semver.IncMinor"]},"contractCommand":["go","test","./..."],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/Masterminds/semver/v3@v3.2.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/Masterminds/semver/v3@v3.2.0","symbols":["semver.IncMinor"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26
require github.com/Masterminds/semver/v3 v3.2.0
github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g=
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
package sample
import (
"fmt"
"github.com/Masterminds/semver/v3"
)
// IncrementMinor increments the minor version segment of a semantic version string.
// It resets the patch segment to 0 and clears any prerelease or build metadata.
func IncrementMinor(vStr string) (string, error) {
v, err := semver.NewVersion(vStr)
if err != nil {
return "", fmt.Errorf("invalid semver %q: %w", vStr, err)
}
inc := v.IncMinor()
return inc.String(), nil
}
// IncrementMinorVersion increments the minor version segment of a semver.Version instance.
// Returns a new semver.Version value with minor bumped, patch reset to 0, and prerelease/metadata cleared.
func IncrementMinorVersion(v *semver.Version) semver.Version {
return v.IncMinor()
}
{
"schemaVersion": 1,
"goal": "verify semver.IncMinor in pkg:golang/github.com/Masterminds/semver/v3@v3.2.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/Masterminds/semver/v3@v3.2.0"
],
"symbols": [
"semver.IncMinor"
]
}
package test
import (
"testing"
"example.com/sample"
"github.com/Masterminds/semver/v3"
)
func TestIncMinorRelease(t *testing.T) {
v, err := semver.NewVersion("1.2.3")
if err != nil {
t.Fatalf("unexpected error parsing version: %v", err)
}
next := v.IncMinor()
if next.Major() != 1 {
t.Errorf("expected major 1, got %d", next.Major())
}
if next.Minor() != 3 {
t.Errorf("expected minor 3, got %d", next.Minor())
}
if next.Patch() != 0 {
t.Errorf("expected patch 0, got %d", next.Patch())
}
if next.String() != "1.3.0" {
t.Errorf("expected string '1.3.0', got '%s'", next.String())
}
// Verify original version remains unchanged
if v.String() != "1.2.3" {
t.Errorf("expected original version to remain '1.2.3', got '%s'", v.String())
}
}
func TestIncMinorPrereleaseAndMetadata(t *testing.T) {
v, err := semver.NewVersion("2.4.9-alpha.1+build.2024")
if err != nil {
t.Fatalf("unexpected error parsing prerelease version: %v", err)
}
next := v.IncMinor()
if next.Major() != 2 {
t.Errorf("expected major 2, got %d", next.Major())
}
if next.Minor() != 5 {
t.Errorf("expected minor 5, got %d", next.Minor())
}
if next.Patch() != 0 {
t.Errorf("expected patch 0, got %d", next.Patch())
}
if next.Prerelease() != "" {
t.Errorf("expected empty prerelease, got '%s'", next.Prerelease())
}
if next.Metadata() != "" {
t.Errorf("expected empty metadata, got '%s'", next.Metadata())
}
if next.String() != "2.5.0" {
t.Errorf("expected string '2.5.0', got '%s'", next.String())
}
}
func TestSampleIncrementMinor(t *testing.T) {
result, err := sample.IncrementMinor("0.1.5")
if err != nil {
t.Fatalf("unexpected error in sample.IncrementMinor: %v", err)
}
if result != "0.2.0" {
t.Errorf("expected '0.2.0', got '%s'", result)
}
_, err = sample.IncrementMinor("invalid-semver")
if err == nil {
t.Errorf("expected error for invalid semver, got nil")
}
v, err := semver.NewVersion("3.7.1-rc.2")
if err != nil {
t.Fatalf("unexpected error parsing version: %v", err)
}
vInc := sample.IncrementMinorVersion(v)
if vInc.String() != "3.8.0" {
t.Errorf("expected '3.8.0', got '%s'", vInc.String())
}
}
原始种子者
匿名