本文へスキップ
Skillpedia
APIとサーバー(バックエンド)48k · #4791

grpc-golang

できること

このスキルは、gRPCを使ってGoで安全かつ効率的な通信サービスを作る手助けをします。プログラム同士がどのように通信するかを定義する方法、通信の安全性をmTLSで確保する方法、そして通信の状況を監視する方法を学べます。

使う場面

  • ✓プログラム同士が素早く、かつ安全にやり取りする必要があるシステムを作るとき。
  • ✓ソフトウェアの異なる部分が、どのように情報をやり取りするかを決めたいとき。
  • ✓高いパフォーマンスとセキュリティが求められる内部APIを作るとき。

スキルのリンク

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/grpc-golang/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/grpc-golang/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“gRPCを使って、Goのサービス同士を安全に通信させるにはどう設定すればよいですか(mTLS)?”

毎週5つの新しいスキル。1分で読めます。

仕組み

スキルは、通信の取り決めを定義する手順(ProtobufとBufを使用)を案内します。さらに、許可されたサービスだけが通信できるようにセキュリティを設定する方法(mTLS)や、通信量とパフォーマンスを監視するツールの追加方法も案内します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

gRPC Golang (gRPC-Go)

Overview

Comprehensive guide for designing and implementing production-grade gRPC services in Go. Covers contract standardization with Buf, transport layer security via mTLS, and deep observability with OpenTelemetry interceptors.

Use this skill when

  • Designing microservices communication with gRPC in Go.
  • Building high-performance internal APIs using Protobuf.
  • Implementing streaming workloads (unidirectional or bidirectional).
  • Standardizing API contracts using Protobuf and Buf.
  • Configuring mTLS for service-to-service authentication.

Do not use this skill when

  • Building pure REST/HTTP public APIs without gRPC requirements.
  • Modifying legacy .proto files without the ability to introduce a new API version (e.g., api.v2) or ensure backward compatibility.
  • Managing service mesh traffic routing (e.g., Istio/Linkerd), which is outside the application code scope.

Step-by-Step Guide

  1. Confirm Technical Context: Identify Go version, gRPC-Go version, and whether the project uses Buf or raw protoc.
  2. Confirm Requirements: Identify mTLS needs, load patterns (unary/streaming), SLOs, and message size limits.
  3. Plan Schema: Define package versioning (e.g., api.v1), resource types, and error mapping.
  4. Security Design: Implement mTLS for service-to-service authentication.
  5. Observability: Configure interceptors for tracing, metrics, and structured logging.
  6. Verification: Always run buf lint and breaking change checks before finalizing code generation.

Refer to resources/implementation-playbook.md for detailed patterns, code examples, and anti-patterns.

Examples

Example 1: Defining a Service & Message (v1 API)

syntax = "proto3";
package api.v1;
option go_package = "github.com/org/repo/gen/api/v1;apiv1";

service UserService {
  rpc GetUser(GetUserRequest) returns (GetUserResponse);
}

message User {
  string id = 1;
  string name = 2;
}

message GetUserRequest {
  string id = 1;
}

message GetUserResponse {
  User user = 1;
}

Best Practices

  • ✅ Do: Use Buf to standardize your toolchain and linting with buf.yaml and buf.gen.yaml.
  • ✅ Do: Always use semantic versioning in package paths (e.g., package api.v1).
  • ✅ Do: Enforce mTLS for all internal service-to-service communication.
  • ✅ Do: Handle ctx.Done() in all streaming handlers to prevent resource leaks.
  • ✅ Do: Map domain errors to standard gRPC status codes (e.g., codes.NotFound).
  • ❌ Don't: Return raw internal error strings or stack traces to gRPC clients.
  • ❌ Don't: Create a new grpc.ClientConn per request; always reuse connections.

Troubleshooting

  • Error: Inconsistent Gen: If the generated code does not match the schema, run buf generate and verify the go_package option.
  • Error: Context Deadline: Check client timeouts and ensure the server is not blocking infinitely in streaming handlers.
  • Error: mTLS Handshake: Ensure the CA certificate is correctly added to the x509.CertPool on both client and server sides.

Limitations

  • Does not cover service mesh traffic routing (Istio/Linkerd configuration).
  • Does not cover gRPC-Web or browser-based gRPC integration.
  • Assumes Go 1.21+ and gRPC-Go v1.60+; older versions may have different APIs (e.g., grpc.Dial vs grpc.NewClient).
  • Does not cover L7 gRPC-aware load balancer configuration (e.g., Envoy, NGINX).
  • Does not address Protobuf schema registry or large-scale schema governance beyond Buf lint.

Resources

Related Skills

  • @golang-pro - General Go patterns and performance optimization outside the gRPC layer.
  • @go-concurrency-patterns - Advanced goroutine lifecycle management for streaming handlers.
  • @api-design-principles - Resource naming and versioning strategy before writing .proto files.
  • @docker-expert - Containerizing gRPC services and configuring TLS cert injection via Docker secrets.
よくある質問

gRPCとProtobufとは何ですか?

gRPCは、プログラム同士がネットワーク越しにやり取りするための仕組みです。Protobufは、やり取りするメッセージの形を定義するための言語で、通信を効率よくします。

mTLSとは何ですか?

mTLS(相互TLS)は、通信の前にクライアントとサーバーの両方が互いを確認するセキュリティの仕組みです。不正なアクセスを防ぎます。

Bufとは何ですか?

Bufは、メッセージの定義ファイル(Protobuf)を管理し、ルールを統一してコード生成を行いやすくするツールです。

詳細

作者による元の説明

Build production-ready gRPC services in Go with mTLS, streaming, and observability. Use when designing Protobuf contracts with Buf or implementing secure service-to-service transport.

repo: sickn33/agentic-awesome-skills

人気

GitHubのスター
48k
ランキング
#4791
ライセンス
MIT
更新日
2026/10/15

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル