CodeSampleX

샘플

google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7: serviceconfig.Service

검증된 샘플 — golang google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7: serviceconfig.Service. go 1.26 · linux debian/x64 · docker에서…

sha256:e8acf53eecd350d0aed42ea2723a806861d7fdc8478230ab3a508c34bee2c9fd

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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-09-01

케이스

HOW
목표
verify google.golang.org/genproto/googleapis/api/serviceconfig.Service in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20240826202546-f6391c0de4c7
패키지
심벌
  • google.golang.org/genproto/googleapis/api/serviceconfig.Service
생성일
2026-09-01T11:32:24Z

컨트랙트

  1. serviceconfig.Service can be instantiated with Name, Title, Id, and ProducerProjectId
  2. Service.GetName returns the configured service name
  3. Service.GetTitle returns the configured service title
  4. Service.GetId returns the configured service ID
  5. Service.GetProducerProjectId returns the configured producer project ID
  6. NewService helper creates a configured serviceconfig.Service
  7. GetServiceName, GetServiceTitle, GetServiceId, and GetProducerProjectId return the respective field values
  8. GetServiceName returns empty string on nil service

파일

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • service.go
  • spec.json
  • test/contract.go

소스 아티팩트 내려받기 (tar.gz)

소스

PROMPT.md
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/api/serviceconfig.Service in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20240826202546-f6391c0de4c7
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20240826202546-f6391c0de4c7
Demonstrate these symbols/APIs:
  - google.golang.org/genproto/googleapis/api/serviceconfig.Service

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.
csx.json
{"case":{"caseId":"case:sha256:c975b0f430bdffcfc2e2e41ca03289c26283265e4216cb3acd857d822ec40008","contract":["serviceconfig.Service can be instantiated with Name, Title, Id, and ProducerProjectId","Service.GetName returns the configured service name","Service.GetTitle returns the configured service title","Service.GetId returns the configured service ID","Service.GetProducerProjectId returns the configured producer project ID","NewService helper creates a configured serviceconfig.Service","GetServiceName, GetServiceTitle, GetServiceId, and GetProducerProjectId return the respective field values","GetServiceName returns empty string on nil service"],"goal":"verify google.golang.org/genproto/googleapis/api/serviceconfig.Service in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20240826202546-f6391c0de4c7","kind":"HOW","packages":["pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20240826202546-f6391c0de4c7"],"schemaVersion":1,"symbols":["google.golang.org/genproto/googleapis/api/serviceconfig.Service"]},"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/api@v0.0.0-20240826202546-f6391c0de4c7"],"schemaVersion":1,"subject":"pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20240826202546-f6391c0de4c7","symbols":["google.golang.org/genproto/googleapis/api/serviceconfig.Service"],"verifierAdapter":"golang@1"}
go.mod
module sample

go 1.22

require google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7

require google.golang.org/protobuf v1.34.2 // indirect
go.sum
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/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 h1:YcyjlL1PRr2Q17/I0dPk2JmYS5CDXfcdb2Z3YRioEbw=
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7/go.mod h1:OCdP9MfskevB/rbYvHTsXTtKC+3bHWajPdoKgjcYkfo=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
service.go
package sample

import (
	"google.golang.org/genproto/googleapis/api/serviceconfig"
)

// NewService creates a new serviceconfig.Service instance with provided metadata.
func NewService(name, title, id, producerProjectId string) *serviceconfig.Service {
	return &serviceconfig.Service{
		Name:              name,
		Title:             title,
		Id:                id,
		ProducerProjectId: producerProjectId,
	}
}

// GetServiceName returns the name of the service using GetName().
func GetServiceName(svc *serviceconfig.Service) string {
	if svc == nil {
		return ""
	}
	return svc.GetName()
}

// GetServiceTitle returns the title of the service using GetTitle().
func GetServiceTitle(svc *serviceconfig.Service) string {
	if svc == nil {
		return ""
	}
	return svc.GetTitle()
}

// GetServiceId returns the ID of the service using GetId().
func GetServiceId(svc *serviceconfig.Service) string {
	if svc == nil {
		return ""
	}
	return svc.GetId()
}

// GetProducerProjectId returns the producer project ID of the service using GetProducerProjectId().
func GetProducerProjectId(svc *serviceconfig.Service) string {
	if svc == nil {
		return ""
	}
	return svc.GetProducerProjectId()
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify google.golang.org/genproto/googleapis/api/serviceconfig.Service in pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20240826202546-f6391c0de4c7",
  "kind": "HOW",
  "packages": [
    "pkg:golang/google.golang.org/genproto/googleapis/api@v0.0.0-20240826202546-f6391c0de4c7"
  ],
  "symbols": [
    "google.golang.org/genproto/googleapis/api/serviceconfig.Service"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"google.golang.org/genproto/googleapis/api/serviceconfig"
	"sample"
)

func main() {
	// Assertion 1: instantiate serviceconfig.Service directly
	svc := &serviceconfig.Service{
		Name:              "endpoints.example.com",
		Title:             "Example API",
		Id:                "2024-08-26r0",
		ProducerProjectId: "example-project-123",
	}

	// Assertion 2: GetName returns the service name
	if got := svc.GetName(); got != "endpoints.example.com" {
		fmt.Fprintf(os.Stderr, "expected GetName() to return %q, got %q\n", "endpoints.example.com", got)
		os.Exit(1)
	}

	// Assertion 3: GetTitle returns the service title
	if got := svc.GetTitle(); got != "Example API" {
		fmt.Fprintf(os.Stderr, "expected GetTitle() to return %q, got %q\n", "Example API", got)
		os.Exit(1)
	}

	// Assertion 4: GetId returns the service ID
	if got := svc.GetId(); got != "2024-08-26r0" {
		fmt.Fprintf(os.Stderr, "expected GetId() to return %q, got %q\n", "2024-08-26r0", got)
		os.Exit(1)
	}

	// Assertion 5: GetProducerProjectId returns the producer project ID
	if got := svc.GetProducerProjectId(); got != "example-project-123" {
		fmt.Fprintf(os.Stderr, "expected GetProducerProjectId() to return %q, got %q\n", "example-project-123", got)
		os.Exit(1)
	}

	// Assertion 6: Helper NewService initializes fields properly
	helperSvc := sample.NewService("endpoints.example.com", "Example API", "2024-08-26r0", "example-project-123")
	if helperSvc == nil {
		fmt.Fprintf(os.Stderr, "expected NewService to return non-nil\n")
		os.Exit(1)
	}

	// Assertion 7: Helper functions extract correct field values
	if got := sample.GetServiceName(helperSvc); got != "endpoints.example.com" {
		fmt.Fprintf(os.Stderr, "expected GetServiceName() to return %q, got %q\n", "endpoints.example.com", got)
		os.Exit(1)
	}
	if got := sample.GetServiceTitle(helperSvc); got != "Example API" {
		fmt.Fprintf(os.Stderr, "expected GetServiceTitle() to return %q, got %q\n", "Example API", got)
		os.Exit(1)
	}
	if got := sample.GetServiceId(helperSvc); got != "2024-08-26r0" {
		fmt.Fprintf(os.Stderr, "expected GetServiceId() to return %q, got %q\n", "2024-08-26r0", got)
		os.Exit(1)
	}
	if got := sample.GetProducerProjectId(helperSvc); got != "example-project-123" {
		fmt.Fprintf(os.Stderr, "expected GetProducerProjectId() to return %q, got %q\n", "example-project-123", got)
		os.Exit(1)
	}

	// Assertion 8: Nil safety in helper functions
	if got := sample.GetServiceName(nil); got != "" {
		fmt.Fprintf(os.Stderr, "expected GetServiceName(nil) to return empty string, got %q\n", got)
		os.Exit(1)
	}

	fmt.Println("All google.golang.org/genproto/googleapis/api/serviceconfig.Service contract assertions passed.")
}

오리진 시더

익명