샘플
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9: errdetails.LocalizedMessage
검증된 샘플 — golang google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9: errdetails.LocalizedMessage. go 1.26 · linux alpine/x64 …
sha256:cee7a56eb92c5e47b8182ae7a77f35233a4bff500d7c896902d4de03cc037f43
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 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-27 |
케이스
HOW- 목표
- verify google.golang.org/genproto/googleapis/rpc/errdetails.LocalizedMessage in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9
- 심벌
-
- google.golang.org/genproto/googleapis/rpc/errdetails.LocalizedMessage
- 생성일
- 2026-08-27T11:41:02Z
컨트랙트
- LocalizedMessage sets and gets locale and message fields
- LocalizedMessage marshals to and unmarshals from binary protobuf format
- LocalizedMessage packs into and unpacks from anypb.Any protobuf container
- LocalizedMessage attaches to status.Status details for RPC error communication
- LocalizedMessage supports multiple distinct locales in error status details
- LocalizedMessage zero value and reset behaviors conform to protobuf message specification
파일
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- 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/genproto/googleapis/rpc/errdetails.LocalizedMessage in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9
Demonstrate these symbols/APIs:
- google.golang.org/genproto/googleapis/rpc/errdetails.LocalizedMessage
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: esm
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:766d99b6df994bdb15ed34b76c095694edc82090959b356ac01c9ea85ad90774","contract":["LocalizedMessage sets and gets locale and message fields","LocalizedMessage marshals to and unmarshals from binary protobuf format","LocalizedMessage packs into and unpacks from anypb.Any protobuf container","LocalizedMessage attaches to status.Status details for RPC error communication","LocalizedMessage supports multiple distinct locales in error status details","LocalizedMessage zero value and reset behaviors conform to protobuf message specification"],"goal":"verify google.golang.org/genproto/googleapis/rpc/errdetails.LocalizedMessage in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9","kind":"HOW","packages":["pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9"],"schemaVersion":1,"symbols":["google.golang.org/genproto/googleapis/rpc/errdetails.LocalizedMessage"]},"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/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9","symbols":["google.golang.org/genproto/googleapis/rpc/errdetails.LocalizedMessage"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.22
require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9
google.golang.org/protobuf v1.35.1
)
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 h1:QCqS/PdaHTSWGvupk2F/ehwHtGc0/GYkT+3GAcR1CCc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
package main
import (
"fmt"
"log"
"google.golang.org/genproto/googleapis/rpc/code"
"google.golang.org/genproto/googleapis/rpc/errdetails"
"google.golang.org/genproto/googleapis/rpc/status"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
)
func main() {
// Create localized messages for different user locales
enMsg := &errdetails.LocalizedMessage{
Locale: "en-US",
Message: "The requested item is out of stock.",
}
koMsg := &errdetails.LocalizedMessage{
Locale: "ko-KR",
Message: "요청하신 상품의 재고가 소진되었습니다.",
}
// Pack localized messages into anypb.Any containers
anyEn, err := anypb.New(enMsg)
if err != nil {
log.Fatalf("failed to pack English localized message: %v", err)
}
anyKo, err := anypb.New(koMsg)
if err != nil {
log.Fatalf("failed to pack Korean localized message: %v", err)
}
// Attach localized messages to RPC status details
st := &status.Status{
Code: int32(code.Code_FAILED_PRECONDITION),
Message: "Item out of stock",
Details: []*anypb.Any{anyEn, anyKo},
}
// Serialize status message to binary protobuf
payload, err := proto.Marshal(st)
if err != nil {
log.Fatalf("failed to marshal status: %v", err)
}
// Deserialize status message
var decoded status.Status
if err := proto.Unmarshal(payload, &decoded); err != nil {
log.Fatalf("failed to unmarshal status: %v", err)
}
fmt.Printf("Status Code: %d\n", decoded.GetCode())
fmt.Printf("Status Message: %s\n", decoded.GetMessage())
fmt.Printf("Details Count: %d\n", len(decoded.GetDetails()))
// Unpack and display each LocalizedMessage detail
for idx, anyDetail := range decoded.GetDetails() {
var locMsg errdetails.LocalizedMessage
if err := anypb.UnmarshalTo(anyDetail, &locMsg, proto.UnmarshalOptions{}); err != nil {
log.Fatalf("failed to unpack detail #%d: %v", idx, err)
}
fmt.Printf("Detail [%d] Locale: %s, Message: %s\n", idx, locMsg.GetLocale(), locMsg.GetMessage())
}
}
{
"schemaVersion": 1,
"goal": "verify google.golang.org/genproto/googleapis/rpc/errdetails.LocalizedMessage in pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9",
"kind": "HOW",
"packages": [
"pkg:golang/google.golang.org/genproto/googleapis/rpc@v0.0.0-20241007155032-5fefd90f89a9"
],
"symbols": [
"google.golang.org/genproto/googleapis/rpc/errdetails.LocalizedMessage"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "esm",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
package main
import (
"fmt"
"os"
"google.golang.org/genproto/googleapis/rpc/code"
"google.golang.org/genproto/googleapis/rpc/errdetails"
"google.golang.org/genproto/googleapis/rpc/status"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
)
func assert(condition bool, message string) {
if !condition {
fmt.Fprintf(os.Stderr, "Assertion failed: %s\n", message)
os.Exit(1)
}
}
func main() {
// 1. LocalizedMessage sets and gets locale and message fields
msg := &errdetails.LocalizedMessage{
Locale: "en-US",
Message: "The requested entity was not found.",
}
assert(msg.GetLocale() == "en-US", "Locale must match en-US")
assert(msg.GetMessage() == "The requested entity was not found.", "Message must match")
// 2. LocalizedMessage marshals to and unmarshals from binary protobuf format
data, err := proto.Marshal(msg)
assert(err == nil, "proto.Marshal(msg) should succeed")
assert(len(data) > 0, "marshaled bytes should not be empty")
var unmarshaledMsg errdetails.LocalizedMessage
err = proto.Unmarshal(data, &unmarshaledMsg)
assert(err == nil, "proto.Unmarshal should succeed")
assert(unmarshaledMsg.GetLocale() == "en-US", "unmarshaled Locale must match en-US")
assert(unmarshaledMsg.GetMessage() == "The requested entity was not found.", "unmarshaled Message must match")
// 3. LocalizedMessage packs into and unpacks from anypb.Any protobuf container
anyMsg, err := anypb.New(msg)
assert(err == nil, "anypb.New(msg) should succeed")
assert(anyMsg.MessageIs(&errdetails.LocalizedMessage{}), "anyMsg should match LocalizedMessage type")
var unpackedMsg errdetails.LocalizedMessage
err = anypb.UnmarshalTo(anyMsg, &unpackedMsg, proto.UnmarshalOptions{})
assert(err == nil, "anypb.UnmarshalTo should succeed")
assert(unpackedMsg.GetLocale() == "en-US", "unpacked Locale must match en-US")
assert(unpackedMsg.GetMessage() == "The requested entity was not found.", "unpacked Message must match")
// 4. LocalizedMessage attaches to status.Status details for RPC error communication
st := &status.Status{
Code: int32(code.Code_NOT_FOUND),
Message: "Resource not found",
Details: []*anypb.Any{anyMsg},
}
assert(st.GetCode() == int32(code.Code_NOT_FOUND), "status code should match NOT_FOUND")
assert(len(st.GetDetails()) == 1, "details count should be 1")
stData, err := proto.Marshal(st)
assert(err == nil, "proto.Marshal(st) should succeed")
var decodedSt status.Status
err = proto.Unmarshal(stData, &decodedSt)
assert(err == nil, "proto.Unmarshal(stData) should succeed")
assert(len(decodedSt.GetDetails()) == 1, "decoded details count should be 1")
var extractedMsg errdetails.LocalizedMessage
err = anypb.UnmarshalTo(decodedSt.GetDetails()[0], &extractedMsg, proto.UnmarshalOptions{})
assert(err == nil, "unmarshaling detail to LocalizedMessage should succeed")
assert(extractedMsg.GetLocale() == "en-US", "extracted Locale must match en-US")
assert(extractedMsg.GetMessage() == "The requested entity was not found.", "extracted Message must match")
// 5. LocalizedMessage supports multiple distinct locales in error status details
locales := []struct {
locale string
message string
}{
{"en-US", "Item out of stock."},
{"ko-KR", "상품 재고가 없습니다."},
{"ja-JP", "商品の在庫がありません。"},
{"fr-FR", "L'article est en rupture de stock."},
}
var detailAnys []*anypb.Any
for _, l := range locales {
lm := &errdetails.LocalizedMessage{
Locale: l.locale,
Message: l.message,
}
a, err := anypb.New(lm)
assert(err == nil, fmt.Sprintf("anypb.New for locale %s should succeed", l.locale))
detailAnys = append(detailAnys, a)
}
multiStatus := &status.Status{
Code: int32(code.Code_FAILED_PRECONDITION),
Message: "Inventory precondition failed",
Details: detailAnys,
}
assert(len(multiStatus.GetDetails()) == len(locales), "multiStatus details count must match locales count")
for idx, anyDetail := range multiStatus.GetDetails() {
var lm errdetails.LocalizedMessage
err = anypb.UnmarshalTo(anyDetail, &lm, proto.UnmarshalOptions{})
assert(err == nil, "unmarshal multi detail should succeed")
assert(lm.GetLocale() == locales[idx].locale, fmt.Sprintf("locale at %d must match %s", idx, locales[idx].locale))
assert(lm.GetMessage() == locales[idx].message, fmt.Sprintf("message at %d must match %s", idx, locales[idx].message))
}
// 6. LocalizedMessage zero value and reset behaviors conform to protobuf message specification
zeroMsg := &errdetails.LocalizedMessage{}
assert(zeroMsg.GetLocale() == "", "zero value locale must be empty string")
assert(zeroMsg.GetMessage() == "", "zero value message must be empty string")
msgToReset := &errdetails.LocalizedMessage{
Locale: "es-ES",
Message: "Recurso no encontrado",
}
msgToReset.Reset()
assert(msgToReset.GetLocale() == "", "reset message locale must be empty")
assert(msgToReset.GetMessage() == "", "reset message text must be empty")
fmt.Println("All LocalizedMessage contract assertions passed successfully.")
}
오리진 시더
익명