示例
Convert between dynamic Go data structures and Protocol Buffers Struct, ListValue, and Value with structpb
sha256:5da721c1166d04ed80369d75435c1584df3cd3d121055f0c4872d4ebf8d74090
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
go linux 24 · ubuntu · glibc 2.39 x64 go go go
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-28 |
案例
HOW- 目标
- Convert between dynamic Go data structures and Protocol Buffers Struct, ListValue, and Value with structpb
- 符号
-
- google.golang.org/protobuf/types/known/structpb.ListValue.AsSlice
- google.golang.org/protobuf/types/known/structpb.NewList
- google.golang.org/protobuf/types/known/structpb.NewStruct
- google.golang.org/protobuf/types/known/structpb.NewValue
- google.golang.org/protobuf/types/known/structpb.Struct.AsMap
- google.golang.org/protobuf/types/known/structpb.Value.AsInterface
- 环境
- go
- 创建时间
- 2026-08-28T09:04:35Z
契约
- structpb.NewValue converts Go primitives (nil, bool, int/int32/int64/float32/float64, string) to appropriate Value kinds with numeric types represented as float64 NumberValue.
- structpb.NewStruct converts Go maps into *structpb.Struct, and Struct.AsMap converts it back to map[string]interface{}, while calling AsMap on a nil receiver safely returns an empty non-nil map.
- structpb.NewList converts Go slices into *structpb.ListValue, and ListValue.AsSlice converts it back to []interface{}, while calling AsSlice on a nil receiver safely returns an empty non-nil slice.
- structpb.Value.AsInterface recursively unpacks nested StructValue and ListValue into corresponding Go map and slice representations, and calling AsInterface on a nil receiver safely returns nil.
- structpb.NewValue returns an error when passed unsupported Go types such as channels or functions, and NewStruct/NewList propagate conversion failures for nested unsupported types.
- structpb.Struct supports proto binary wire serialization and protojson serialization formatting as a standard JSON object.
文件
- NOTES.md
- PROMPT.md
- csx.json
- go.mod
- go.sum
- spec.json
- structpb_test.go
原始种子者
匿名