> For the complete documentation index, see [llms.txt](https://docs.wantedly.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wantedly.dev/fields/the-system/grpc-in-go.md).

# 実践: gRPC in Go

本章では、 「Wantedly で Go を使って gRPC Server/Client の開発をどう行なっているのか」について紹介します。

## Go で gRPC Server を作る

Wantedly では [grapi](https://github.com/izumin5210/grapi) という小さなフレームワークを使って gRPC server を実装します。 詳しくは下記のスライドおよび記事を参照してください。

* [grapi: Bulding JSON API server with grpc-gateway for microservices - Speaker Deck](https://speakerdeck.com/izumin5210/grapi-bulding-json-api-server-with-grpc-gateway-for-microservices)
* [grapi : #golang で interface driven かつボイラプレートに悩まされない API 開発](https://qiita.com/izumin5210/items/ed1c0100a45366c3b75e)

grapi が生成したコードに servicex の設定を組み込む必要があります。これは [servicex-go の README (internal)](https://github.com/wantedly/servicex-go) を参照してください。

## Go で gRPC Client を使う

基本的には [gRPC 公式の Quick start](https://grpc.io/docs/languages/go/quickstart/) と同じになります。 ただ、Ruby と同じくクライアントの初期化については servicex の実装を使う必要があります。

```golang
cc, err := grpcx.DialContext(ctx, apix.UsersGrpcBaseURLs.Default().String())
if err != nil {
	// ...
}
client := users_pb.NewProfileServiceClient(cc)
```

#### 話を聞きに行きたい

* Slack: [#gophers](https://wantedly.slack.com/archives/CA69S8BBP)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.wantedly.dev/fields/the-system/grpc-in-go.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
