샘플
google.golang.org/protobuf v1.36.4: proto.Equal
검증된 샘플 — golang google.golang.org/protobuf v1.36.4: proto.Equal. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: proto.Equal returns true when…
sha256:7fdc425068384ec073f76afc7fa20b2e533f16a934cd93f12195c2aeee4930bf
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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-24 |
케이스
HOW- 목표
- verify google.golang.org/protobuf/proto.Equal in pkg:golang/google.golang.org/protobuf@v1.36.4
- 심벌
-
- google.golang.org/protobuf/proto.Equal
- 생성일
- 2026-10-24T13:31:54Z
컨트랙트
- proto.Equal returns true when comparing two untyped nil values or two typed nil pointers of the same message type
- proto.Equal returns false when comparing an untyped nil interface with a typed nil message pointer
- proto.Equal returns false when comparing messages with different descriptors even when both are empty or typed nil
- proto.Equal returns true for distinct message instances with identical scalar field values and false when scalar fields differ
- proto.Equal distinguishes unset proto2 fields from explicitly set zero-value proto2 fields
- proto.Equal treats floating-point NaN values as equal while distinguishing positive and negative zero
- proto.Equal compares map entries independent of insertion order and repeated list elements in order
- proto.Equal includes unparsed unknown wire fields in equality comparisons
파일
- PROMPT.md
- csx.json
- go.mod
- go.sum
- 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 google.golang.org/protobuf/proto.Equal in pkg:golang/google.golang.org/protobuf@v1.36.4
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/google.golang.org/protobuf@v1.36.4
Demonstrate these symbols/APIs:
- google.golang.org/protobuf/proto.Equal
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:4bf0d44fb9296d185fc5c12378195c502a8f14d650061b3da0def2a69df5d3a1","contract":["proto.Equal returns true when comparing two untyped nil values or two typed nil pointers of the same message type","proto.Equal returns false when comparing an untyped nil interface with a typed nil message pointer","proto.Equal returns false when comparing messages with different descriptors even when both are empty or typed nil","proto.Equal returns true for distinct message instances with identical scalar field values and false when scalar fields differ","proto.Equal distinguishes unset proto2 fields from explicitly set zero-value proto2 fields","proto.Equal treats floating-point NaN values as equal while distinguishing positive and negative zero","proto.Equal compares map entries independent of insertion order and repeated list elements in order","proto.Equal includes unparsed unknown wire fields in equality comparisons"],"goal":"verify google.golang.org/protobuf/proto.Equal in pkg:golang/google.golang.org/protobuf@v1.36.4","kind":"HOW","packages":["pkg:golang/google.golang.org/protobuf@v1.36.4"],"schemaVersion":1,"symbols":["google.golang.org/protobuf/proto.Equal"]},"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/google.golang.org/protobuf@v1.36.4"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/protobuf@v1.36.4","symbols":["google.golang.org/protobuf/proto.Equal"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.21
require google.golang.org/protobuf v1.36.4
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM=
google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
{
"schemaVersion": 1,
"goal": "verify google.golang.org/protobuf/proto.Equal in pkg:golang/google.golang.org/protobuf@v1.36.4",
"kind": "HOW",
"packages": [
"pkg:golang/google.golang.org/protobuf@v1.36.4"
],
"symbols": [
"google.golang.org/protobuf/proto.Equal"
]
}
package main
import (
"fmt"
"math"
"os"
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/descriptorpb"
"google.golang.org/protobuf/types/known/structpb"
"google.golang.org/protobuf/types/known/wrapperspb"
)
func assert(cond bool, msg string) {
if !cond {
fmt.Fprintln(os.Stderr, "contract failed:", msg)
os.Exit(1)
}
}
func main() {
// 1. Untyped nil and typed nil of the same message type
var untypedA, untypedB proto.Message
assert(proto.Equal(untypedA, untypedB), "two untyped nil messages must be equal")
var typedNilStrA, typedNilStrB *wrapperspb.StringValue
assert(proto.Equal(typedNilStrA, typedNilStrB), "two typed nil pointers of the same message type must be equal")
// 2. Untyped nil vs typed nil pointer
assert(!proto.Equal(untypedA, typedNilStrA), "untyped nil and typed nil message pointer must not be equal")
// 3. Different message descriptors (empty or typed nil)
var typedNilInt *wrapperspb.Int64Value
assert(!proto.Equal(typedNilStrA, typedNilInt), "typed nil pointers of different message types must not be equal")
assert(!proto.Equal(&wrapperspb.StringValue{}, &wrapperspb.Int64Value{}), "empty messages of different descriptors must not be equal")
// 4. Scalar field equality and inequality across distinct instances
s1 := wrapperspb.String("hello")
s2 := wrapperspb.String("hello")
s3 := wrapperspb.String("world")
assert(s1 != s2 && proto.Equal(s1, s2), "distinct messages with identical scalar values must be equal")
assert(!proto.Equal(s1, s3), "messages with different scalar values must not be equal")
// 5. Explicit presence (proto2): unset field vs explicitly set zero-value field
unsetProto2 := &descriptorpb.FieldDescriptorProto{}
emptyNameProto2 := &descriptorpb.FieldDescriptorProto{Name: proto.String("")}
sameEmptyNameProto2 := &descriptorpb.FieldDescriptorProto{Name: proto.String("")}
assert(!proto.Equal(unsetProto2, emptyNameProto2), "unset proto2 field must not equal explicitly set empty proto2 field")
assert(proto.Equal(emptyNameProto2, sameEmptyNameProto2), "two proto2 messages with identical explicitly set zero values must be equal")
// 6. IEEE-754 floating-point NaN and signed zeros
nanA := wrapperspb.Double(math.NaN())
nanB := wrapperspb.Double(math.NaN())
assert(proto.Equal(nanA, nanB), "proto.Equal must treat NaN float values as equal")
posZero := wrapperspb.Double(0.0)
negZero := wrapperspb.Double(math.Copysign(0.0, -1.0))
assert(!proto.Equal(posZero, negZero), "proto.Equal must distinguish +0.0 and -0.0")
// 7. Map entries (order-independent) and repeated list elements (order-sensitive)
mapA := &structpb.Struct{
Fields: map[string]*structpb.Value{
"first": structpb.NewNumberValue(1),
"second": structpb.NewStringValue("two"),
},
}
mapB := &structpb.Struct{
Fields: map[string]*structpb.Value{
"second": structpb.NewStringValue("two"),
"first": structpb.NewNumberValue(1),
},
}
mapC := &structpb.Struct{
Fields: map[string]*structpb.Value{
"first": structpb.NewNumberValue(1),
"second": structpb.NewStringValue("different"),
},
}
assert(proto.Equal(mapA, mapB), "map fields with identical key-value pairs must be equal")
assert(!proto.Equal(mapA, mapC), "map fields with differing values must not be equal")
listA := &structpb.ListValue{
Values: []*structpb.Value{
structpb.NewNumberValue(1),
structpb.NewNumberValue(2),
},
}
listB := &structpb.ListValue{
Values: []*structpb.Value{
structpb.NewNumberValue(1),
structpb.NewNumberValue(2),
},
}
listReversed := &structpb.ListValue{
Values: []*structpb.Value{
structpb.NewNumberValue(2),
structpb.NewNumberValue(1),
},
}
assert(proto.Equal(listA, listB), "repeated fields with identical elements in order must be equal")
assert(!proto.Equal(listA, listReversed), "repeated fields with elements in different order must not be equal")
// 8. Unknown wire fields included in equality comparison
var rawUnknown []byte
rawUnknown = protowire.AppendTag(rawUnknown, 999, protowire.VarintType)
rawUnknown = protowire.AppendVarint(rawUnknown, 42)
u1 := wrapperspb.String("payload")
u2 := wrapperspb.String("payload")
u1.ProtoReflect().SetUnknown(rawUnknown)
assert(!proto.Equal(u1, u2), "message with unknown fields must not equal message without unknown fields")
u2.ProtoReflect().SetUnknown(rawUnknown)
assert(proto.Equal(u1, u2), "messages with identical known and unknown fields must be equal")
}
오리진 시더
익명