Beispiel
go.opentelemetry.io/proto/otlp v1.9.0: v1.AnyValue_DoubleValue
Verifiziertes Beispiel für golang go.opentelemetry.io/proto/otlp v1.9.0: v1.AnyValue_DoubleValue. Der Vertrag lief auf go 1.26 · linux debian/x64 · docker…
sha256:a758bad674bece3a4775289748446a94506dd7eabb37b54773b6972676b13db9
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_DoubleValue in pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0
- Symbole
-
- go.opentelemetry.io/proto/otlp/common/v1.AnyValue_DoubleValue
- Erstellt
- 2026-09-05T14:03:39Z
Contract
- AnyValue_DoubleValue wraps a 64-bit float value implementing the isAnyValue_Value interface for AnyValue.Value.
- AnyValue.GetDoubleValue returns the wrapped float64 value when AnyValue_DoubleValue is set, and returns 0.0 when unset or nil.
- Type assertion on AnyValue.GetValue matches *commonpb.AnyValue_DoubleValue and provides direct access to DoubleValue field.
- AnyValue_DoubleValue correctly preserves positive, negative, fractional, zero, and special floating-point values.
- AnyValue containing AnyValue_DoubleValue serializes and deserializes accurately via binary protobuf wire format and proto.Equal.
- AnyValue containing AnyValue_DoubleValue marshals to and unmarshals from protojson format, representing the field as 'doubleValue'.
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_DoubleValue 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_DoubleValue
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:cc35a2c48cd633987411af22e370955c82b7d6e3c975b6931f4c8bd58034985e","contract":["AnyValue_DoubleValue wraps a 64-bit float value implementing the isAnyValue_Value interface for AnyValue.Value.","AnyValue.GetDoubleValue returns the wrapped float64 value when AnyValue_DoubleValue is set, and returns 0.0 when unset or nil.","Type assertion on AnyValue.GetValue matches *commonpb.AnyValue_DoubleValue and provides direct access to DoubleValue field.","AnyValue_DoubleValue correctly preserves positive, negative, fractional, zero, and special floating-point values.","AnyValue containing AnyValue_DoubleValue serializes and deserializes accurately via binary protobuf wire format and proto.Equal.","AnyValue containing AnyValue_DoubleValue marshals to and unmarshals from protojson format, representing the field as 'doubleValue'."],"goal":"verify go.opentelemetry.io/proto/otlp/common/v1.AnyValue_DoubleValue 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_DoubleValue"]},"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_DoubleValue"],"verifierAdapter":"golang@1"}
module example.com/otlpanyvaluedouble
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_DoubleValue 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_DoubleValue"
]
}
package main
import (
"bytes"
"fmt"
"math"
"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_DoubleValue wraps a 64-bit float value implementing the isAnyValue_Value interface for AnyValue.Value.
{
dv := &commonpb.AnyValue_DoubleValue{
DoubleValue: 3.141592653589793,
}
anyVal := &commonpb.AnyValue{
Value: dv,
}
assert(anyVal.GetValue() != nil, "expected non-nil Value")
assert(dv.DoubleValue == 3.141592653589793, "expected matching DoubleValue field")
}
// Assertion 2: AnyValue.GetDoubleValue returns the wrapped float64 value when AnyValue_DoubleValue is set, and returns 0.0 when unset or nil.
{
anyVal := &commonpb.AnyValue{
Value: &commonpb.AnyValue_DoubleValue{DoubleValue: 42.5},
}
assert(anyVal.GetDoubleValue() == 42.5, "expected GetDoubleValue to return 42.5")
emptyVal := &commonpb.AnyValue{}
assert(emptyVal.GetDoubleValue() == 0.0, "expected default 0.0 on empty AnyValue")
var nilVal *commonpb.AnyValue
assert(nilVal.GetDoubleValue() == 0.0, "expected default 0.0 on nil AnyValue")
strVal := &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{StringValue: "not a float"},
}
assert(strVal.GetDoubleValue() == 0.0, "expected default 0.0 on mismatched StringValue variant")
}
// Assertion 3: Type assertion on AnyValue.GetValue matches *commonpb.AnyValue_DoubleValue and provides direct access to DoubleValue field.
{
anyVal := &commonpb.AnyValue{
Value: &commonpb.AnyValue_DoubleValue{DoubleValue: 123.456},
}
dv, ok := anyVal.GetValue().(*commonpb.AnyValue_DoubleValue)
assert(ok, "expected type assertion to *commonpb.AnyValue_DoubleValue to succeed")
assert(dv != nil && dv.DoubleValue == 123.456, "expected dv.DoubleValue to be 123.456")
otherVal := &commonpb.AnyValue{
Value: &commonpb.AnyValue_IntValue{IntValue: 100},
}
_, okOther := otherVal.GetValue().(*commonpb.AnyValue_DoubleValue)
assert(!okOther, "expected type assertion to fail on IntValue variant")
}
// Assertion 4: AnyValue_DoubleValue correctly preserves positive, negative, fractional, zero, and special floating-point values.
{
testCases := []float64{
0.0,
-0.0,
1.0,
-1.0,
0.00000000001,
-9876543210.12345,
math.MaxFloat64,
math.SmallestNonzeroFloat64,
math.Inf(1),
math.Inf(-1),
}
for _, tc := range testCases {
val := &commonpb.AnyValue{
Value: &commonpb.AnyValue_DoubleValue{DoubleValue: tc},
}
assert(val.GetDoubleValue() == tc, fmt.Sprintf("expected %v, got %v", tc, val.GetDoubleValue()))
}
nanVal := &commonpb.AnyValue{
Value: &commonpb.AnyValue_DoubleValue{DoubleValue: math.NaN()},
}
assert(math.IsNaN(nanVal.GetDoubleValue()), "expected NaN value to be preserved")
}
// Assertion 5: AnyValue containing AnyValue_DoubleValue serializes and deserializes accurately via binary protobuf wire format and proto.Equal.
{
orig := &commonpb.AnyValue{
Value: &commonpb.AnyValue_DoubleValue{DoubleValue: 271.8281828},
}
wire, err := proto.Marshal(orig)
assert(err == nil, "proto.Marshal failed")
assert(len(wire) > 0, "marshaled wire length is 0")
unmarshaled := &commonpb.AnyValue{}
err = proto.Unmarshal(wire, unmarshaled)
assert(err == nil, "proto.Unmarshal failed")
assert(proto.Equal(orig, unmarshaled), "proto.Equal returned false for protobuf round-trip")
assert(unmarshaled.GetDoubleValue() == 271.8281828, "unmarshaled GetDoubleValue mismatched")
}
// Assertion 6: AnyValue containing AnyValue_DoubleValue marshals to and unmarshals from protojson format, representing the field as 'doubleValue'.
{
orig := &commonpb.AnyValue{
Value: &commonpb.AnyValue_DoubleValue{DoubleValue: 6.022e23},
}
jsonBytes, err := protojson.Marshal(orig)
assert(err == nil, "protojson.Marshal failed")
assert(bytes.Contains(jsonBytes, []byte(`"doubleValue"`)), "json must contain 'doubleValue'")
jsonUnmarshaled := &commonpb.AnyValue{}
err = protojson.Unmarshal(jsonBytes, jsonUnmarshaled)
assert(err == nil, "protojson.Unmarshal failed")
assert(proto.Equal(orig, jsonUnmarshaled), "proto.Equal returned false for protojson round-trip")
assert(jsonUnmarshaled.GetDoubleValue() == 6.022e23, "json unmarshaled GetDoubleValue mismatched")
}
fmt.Println("PASS: all go.opentelemetry.io/proto/otlp/common/v1.AnyValue_DoubleValue contract assertions verified")
}
Ursprungs-Seeder
anonym