go-grpc

Implements and reviews Go gRPC services from proto contracts through testing and TLS.

1|2|Updated Nov 25, 2017
One-click install
npx skills add https://github.com/asarchami/dotfiles --skill go-grpc-asarchami
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-grpc
Source: https://github.com/asarchami/dotfiles/tree/main/dot_config/opencode/skills/go/go-grpc
Command: npx skills add https://github.com/asarchami/dotfiles --skill go-grpc-asarchami

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building gRPC services in Go involves many failure-prone decisions: proto contract design, error-code mapping, connection management, deadlines, streaming shapes, and transport security. This Skill provides a contract-first workflow with concrete checklists and code patterns so servers and clients are implemented and reviewed correctly. ## Core Features & Use Cases - Contract-first service building: Organize protos in versioned domain directories, use Request/Response wrapper messages, and generate code with buf or protoc. - Server and client guardrails: Health service registration, interceptor chains, graceful shutdown, connection reuse, per-call deadlines, and round_robin load balancing. - Error mapping and testing: Map errors to actionable gRPC status codes with errdetails, and test the full stack in-memory using bufconn with status-code assertions. - Use Case: When reviewing a Go microservice, walk the audit steps to catch raw errors returned instead of status codes, missing client deadlines, reflection enabled in production, and absent health checks. ## Quick Start Ask the assistant to implement a gRPC user service in Go with proto definitions, interceptors, graceful shutdown, and bufconn tests.

Frequently Asked Questions about go-grpc

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement a gRPC service in Go?

Define the .proto contract first in versioned domain directories with Request/Response wrapper messages, then generate code with buf generate or protoc. Implement the generated server interface, register the health service, chain interceptors for cross-cutting concerns, and shut down with GracefulStop plus a timeout fallback.

How do I map Go errors to gRPC status codes?

Return status.Errorf with a specific code such as codes.NotFound or codes.InvalidArgument instead of a raw error, which becomes codes.Unknown. Attach errdetails.BadRequest for field-level validation failures so clients can decide between retry, fail-fast, or degrade.

Should I use buf or protoc for protobuf code generation?

buf is the recommended modern alternative to raw protoc because it manages dependencies, lints protos, and checks breaking changes from a single config. protoc works with explicit flags like --go_out and --go-grpc_out when you need direct control.

How do I test gRPC services without a network?

Use bufconn to create in-memory connections that exercise the full gRPC stack including serialization, interceptors, and metadata. Assert the expected status code of every error branch with status.FromError, and cover streaming RPCs by iterating Recv until io.EOF.

Why does my gRPC client hang on slow upstreams?

Calls without a deadline hang goroutines indefinitely when the upstream is slow. Set context.WithTimeout on every call, reuse a single connection since HTTP/2 multiplexes RPCs, and configure round_robin load balancing with dns:/// for headless Kubernetes services.

When should I use gRPC streaming instead of unary RPCs?

Use server streaming for sequences like log tailing, client streaming for uploads or batches, and bidirectional for real-time exchange. Streaming avoids the default 4 MB per-message size limit and lowers memory pressure compared to large single messages.