Beispiel
go.opentelemetry.io/proto/otlp v1.9.0: v1.AnyValue_BytesValue
Verifiziertes Beispiel für golang go.opentelemetry.io/proto/otlp v1.9.0: v1.AnyValue_BytesValue. Der Vertrag lief auf go 1.26 · linux debian/x64 · docker und…
sha256:156d987452ff15a639fe1d89884f856faca534582218d663a4ee89689f34373b
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
linux 24 · ubuntu · glibc 2.39 x64 go
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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-05 |
Fall
HOW- Ziel
- verify go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BytesValue in pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0
- Symbole
-
- go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BytesValue
- Erstellt
- 2026-09-05T13:42:29Z
Contract
- AnyValue_BytesValue wraps a byte slice into an AnyValue message and can be extracted via GetBytesValue or dynamic type assertion on GetValue.
- AnyValue_BytesValue populates the oneof Value field exclusively, causing other typed getters such as GetStringValue, GetIntValue, and GetDoubleValue to return their zero values.
- AnyValue containing AnyValue_BytesValue serializes to binary Protobuf wire format and deserializes back faithfully, preserving the underlying bytes.
- AnyValue containing AnyValue_BytesValue serializes to protojson format using base64 encoding and deserializes back into an identical message.
- proto.Clone creates an independent deep copy of AnyValue with AnyValue_BytesValue so mutating the cloned byte slice does not affect the original.
Dateien
- PROMPT.md
- csx.json
- go.mod
- go.sum
- spec.json
- test/main.go
Quelltext
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 go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BytesValue in pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0
Demonstrate these symbols/APIs:
- go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BytesValue
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:55e1ac01b361f88dc01bfe05ba3ce0a26a0128bc43bc0678804745f2dff973be","contract":["AnyValue_BytesValue wraps a byte slice into an AnyValue message and can be extracted via GetBytesValue or dynamic type assertion on GetValue.","AnyValue_BytesValue populates the oneof Value field exclusively, causing other typed getters such as GetStringValue, GetIntValue, and GetDoubleValue to return their zero values.","AnyValue containing AnyValue_BytesValue serializes to binary Protobuf wire format and deserializes back faithfully, preserving the underlying bytes.","AnyValue containing AnyValue_BytesValue serializes to protojson format using base64 encoding and deserializes back into an identical message.","proto.Clone creates an independent deep copy of AnyValue with AnyValue_BytesValue so mutating the cloned byte slice does not affect the original."],"goal":"verify go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BytesValue in pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0","kind":"HOW","packages":["pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0"],"schemaVersion":1,"symbols":["go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BytesValue"]},"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/go.opentelemetry.io/proto/otlp@v1.9.0"],"schemaVersion":1,"subject":"pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0","symbols":["go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BytesValue"],"verifierAdapter":"golang@1"}
module example.com/otlpbytesvalue
go 1.26.6
require (
go.opentelemetry.io/proto/otlp v1.9.0
google.golang.org/protobuf v1.36.10
)
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
go.opentelemetry.io/proto/otlp v1.9.0 h1:l706jCMITVouPOqEnii2fIAuO3IVGBRPV5ICjceRb/A=
go.opentelemetry.io/proto/otlp v1.9.0/go.mod h1:xE+Cx5E/eEHw+ISFkwPLwCZefwVjY+pqKg1qcK03+/4=
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
{
"schemaVersion": 1,
"goal": "verify go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BytesValue in pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0",
"kind": "HOW",
"packages": [
"pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0"
],
"symbols": [
"go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BytesValue"
]
}
package main
import (
"bytes"
"fmt"
"os"
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)
func assert(condition bool, message string) {
if !condition {
fmt.Fprintf(os.Stderr, "assertion failed: %s\n", message)
os.Exit(1)
}
}
func main() {
// Assertion 1: AnyValue_BytesValue wraps a byte slice into an AnyValue message and can be extracted via GetBytesValue or dynamic type assertion on GetValue.
{
payload := []byte{0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0xFF}
wrapper := &commonpb.AnyValue_BytesValue{
BytesValue: payload,
}
anyVal := &commonpb.AnyValue{
Value: wrapper,
}
// Verify dynamic type assertion on GetValue()
val := anyVal.GetValue()
typedVal, ok := val.(*commonpb.AnyValue_BytesValue)
assert(ok, "expected Value to type-assert to *commonpb.AnyValue_BytesValue")
assert(bytes.Equal(typedVal.BytesValue, payload), "expected BytesValue to match original payload")
// Verify typed getter GetBytesValue()
extracted := anyVal.GetBytesValue()
assert(bytes.Equal(extracted, payload), "expected GetBytesValue() to return matching payload")
}
// Assertion 2: AnyValue_BytesValue populates the oneof Value field exclusively, causing other typed getters such as GetStringValue, GetIntValue, and GetDoubleValue to return their zero values.
{
payload := []byte("telemetry-payload")
anyVal := &commonpb.AnyValue{
Value: &commonpb.AnyValue_BytesValue{BytesValue: payload},
}
assert(anyVal.GetStringValue() == "", "expected empty string for GetStringValue on AnyValue_BytesValue")
assert(anyVal.GetIntValue() == 0, "expected 0 for GetIntValue on AnyValue_BytesValue")
assert(anyVal.GetDoubleValue() == 0.0, "expected 0.0 for GetDoubleValue on AnyValue_BytesValue")
assert(anyVal.GetBoolValue() == false, "expected false for GetBoolValue on AnyValue_BytesValue")
assert(anyVal.GetArrayValue() == nil, "expected nil for GetArrayValue on AnyValue_BytesValue")
assert(anyVal.GetKvlistValue() == nil, "expected nil for GetKvlistValue on AnyValue_BytesValue")
}
// Assertion 3: AnyValue containing AnyValue_BytesValue serializes to binary Protobuf wire format and deserializes back faithfully, preserving the underlying bytes.
{
payload := []byte{0x10, 0x20, 0x30, 0x40, 0x50}
orig := &commonpb.AnyValue{
Value: &commonpb.AnyValue_BytesValue{BytesValue: payload},
}
wire, err := proto.Marshal(orig)
assert(err == nil, fmt.Sprintf("proto.Marshal failed: %v", err))
assert(len(wire) > 0, "expected non-empty wire bytes")
unmarshaled := &commonpb.AnyValue{}
err = proto.Unmarshal(wire, unmarshaled)
assert(err == nil, fmt.Sprintf("proto.Unmarshal failed: %v", err))
assert(proto.Equal(orig, unmarshaled), "expected unmarshaled AnyValue to equal original")
unmarshaledBytes := unmarshaled.GetBytesValue()
assert(bytes.Equal(unmarshaledBytes, payload), "expected unmarshaled bytes to match original")
}
// Assertion 4: AnyValue containing AnyValue_BytesValue serializes to protojson format using base64 encoding and deserializes back into an identical message.
{
payload := []byte("hello-otlp")
orig := &commonpb.AnyValue{
Value: &commonpb.AnyValue_BytesValue{BytesValue: payload},
}
jsonBytes, err := protojson.Marshal(orig)
assert(err == nil, fmt.Sprintf("protojson.Marshal failed: %v", err))
// Base64 encoding of "hello-otlp" is "aGVsbG8tb3RscA=="
assert(bytes.Contains(jsonBytes, []byte(`"bytesValue"`)), "json must contain 'bytesValue' key")
assert(bytes.Contains(jsonBytes, []byte(`"aGVsbG8tb3RscA=="`)), "json must contain base64-encoded payload")
jsonUnmarshaled := &commonpb.AnyValue{}
err = protojson.Unmarshal(jsonBytes, jsonUnmarshaled)
assert(err == nil, fmt.Sprintf("protojson.Unmarshal failed: %v", err))
assert(proto.Equal(orig, jsonUnmarshaled), "expected protojson round-trip equality")
assert(bytes.Equal(jsonUnmarshaled.GetBytesValue(), payload), "expected json-deserialized bytes to match")
}
// Assertion 5: proto.Clone creates an independent deep copy of AnyValue with AnyValue_BytesValue so mutating the cloned byte slice does not affect the original.
{
origPayload := []byte{0x01, 0x02, 0x03, 0x04}
orig := &commonpb.AnyValue{
Value: &commonpb.AnyValue_BytesValue{BytesValue: origPayload},
}
cloned := proto.Clone(orig).(*commonpb.AnyValue)
assert(proto.Equal(orig, cloned), "cloned AnyValue must equal original")
// Mutate cloned slice
clonedTyped, ok := cloned.GetValue().(*commonpb.AnyValue_BytesValue)
assert(ok, "expected cloned Value to be *commonpb.AnyValue_BytesValue")
clonedTyped.BytesValue[0] = 0x99
// Verify original remains untouched
assert(orig.GetBytesValue()[0] == 0x01, "original bytes were mutated by clone modification")
assert(!proto.Equal(orig, cloned), "original and mutated clone should no longer be equal")
}
fmt.Println("PASS: all go.opentelemetry.io/proto/otlp/common/v1.AnyValue_BytesValue contract assertions verified")
}
Ursprungs-Seeder
anonym