{"id":372,"date":"2026-05-09T09:00:00","date_gmt":"2026-05-09T03:30:00","guid":{"rendered":"https:\/\/smitabharat.com\/blog\/go-grpc-tutorial\/"},"modified":"2026-10-10T21:21:16","modified_gmt":"2026-10-10T15:51:16","slug":"go-grpc-tutorial","status":"publish","type":"post","link":"https:\/\/smitabharat.com\/blog\/go-grpc-tutorial\/","title":{"rendered":"Go gRPC Tutorial: Build Your First gRPC Service"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Go gRPC lets one service call a function on another service, almost as if it were a local function. In this post, you will learn what gRPC is and how it differs from REST. Then we will build a small book service with a server and a client. By the end, you will have a working pattern you can reuse in real microservices.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This lesson builds on two earlier ones. First, you built JSON endpoints in <a href=\"https:\/\/smitabharat.com\/blog\/go-rest-api-tutorial\/\">the Go REST API tutorial<\/a>. Then you learned timeouts and cancellation in <a href=\"https:\/\/smitabharat.com\/blog\/go-context-beginners-guide\/\">Go context for beginners<\/a>. Both ideas come back here, so keep them in mind.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Is Go gRPC?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In short, gRPC is a framework for remote procedure calls, or RPC. An RPC simply means &#8220;call a function that lives on another machine&#8221;. You describe your functions and data once in a <code>.proto<\/code> file. Then a tool generates Go code for both the server and the client.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, think of a restaurant menu. The menu lists every dish and what goes into it, so the customer and the kitchen agree before anyone cooks. In the same way, the <code>.proto<\/code> file is a menu that both services agree on. So the client cannot ask for a dish that does not exist.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Under the hood, Go gRPC sends data in a compact binary format called Protocol Buffers, or protobuf for short. It also runs on HTTP\/2, which keeps one connection open and sends many calls over it at once.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Go gRPC Matters<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">On one hand, REST with JSON works well for browsers and public APIs. However, inside a company, services often talk to each other thousands of times per second. In that case, small messages and strict types matter a lot.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here are common places where teams pick gRPC.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Service to service calls<\/strong>: an order service asks a payment service to charge a card.<\/li>\n\n\n\n<li><strong>Streaming data<\/strong>: a server sends live stock prices or log lines as they happen.<\/li>\n\n\n\n<li><strong>Many languages<\/strong>: a Go service and a Python service share one <code>.proto<\/code> file.<\/li>\n\n\n\n<li><strong>Mobile apps on slow networks<\/strong>: smaller messages mean faster screens.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">In short, Go gRPC shines when speed, strict contracts and streaming matter more than easy browser access.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How Go gRPC Works<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Go gRPC flow has four simple steps. First, you write the contract in a <code>.proto<\/code> file. Next, the <code>protoc<\/code> compiler generates Go code from it. Then you write a server that fills in the generated interface. Finally, the client calls the generated methods like normal Go functions.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-diagram-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-diagram-1-1024x640.png\" alt=\"Go gRPC diagram showing a .proto contract generating client and server code over one HTTP\/2 connection\" class=\"wp-image-343\" srcset=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-diagram-1-1024x640.png 1024w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-diagram-1-300x188.png 300w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-diagram-1-768x480.png 768w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-diagram-1-1536x960.png 1536w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-diagram-1-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">A .proto contract generates Go code for both sides, and the client calls the server over one HTTP\/2 connection using protobuf messages.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Meanwhile, the generated client code does the hard work. First, it turns your Go struct into protobuf bytes and sends them. Then it waits for the reply and turns the bytes back into a struct. As a result, your own code stays short and readable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Key Parts of a Go gRPC Service<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In fact, every Go gRPC project has the same few building blocks. Once you know them, any gRPC codebase becomes easy to read.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The .proto File<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">First, this file defines messages, which are like structs, and services, which are like interfaces. Each field gets a number, such as <code>= 1<\/code>. These numbers identify fields on the wire, so never reuse or change them once a service is live.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Generated Code<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Next, two plugins create the Go code. The <code>protoc-gen-go<\/code> plugin makes the message structs, while <code>protoc-gen-go-grpc<\/code> makes the server interface and the client. You never edit these files by hand.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Server<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Here, you write a struct that implements the service methods. Then you register it on a <code>grpc.Server<\/code> and start listening on a TCP port.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Client<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The client opens a connection with <code>grpc.NewClient<\/code> and calls methods on a generated client value. Each call takes a context, so timeouts work exactly like you learned before.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">RPC Types<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Every Go gRPC service can use four call styles. This table shows them with a simple example for each.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Type<\/th><th>What happens<\/th><th>Example<\/th><\/tr><\/thead><tbody><tr><td>Unary<\/td><td>One request, one response<\/td><td>Get one book by ID<\/td><\/tr><tr><td>Server streaming<\/td><td>One request, many responses<\/td><td>List all books by an author<\/td><\/tr><tr><td>Client streaming<\/td><td>Many requests, one response<\/td><td>Upload many log lines, get a summary<\/td><\/tr><tr><td>Bidirectional<\/td><td>Many requests and responses<\/td><td>A live chat between two services<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Go gRPC vs REST<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Both styles move data between services. However, they make different trade-offs. The table below compares them side by side.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Feature<\/th><th>gRPC<\/th><th>REST with JSON<\/th><\/tr><\/thead><tbody><tr><td>Data format<\/td><td>Binary protobuf<\/td><td>Text JSON<\/td><\/tr><tr><td>Contract<\/td><td>Required <code>.proto<\/code> file<\/td><td>Optional, often OpenAPI<\/td><\/tr><tr><td>Transport<\/td><td>HTTP\/2<\/td><td>Usually HTTP\/1.1<\/td><\/tr><tr><td>Streaming<\/td><td>Built in, four styles<\/td><td>Needs extra tools<\/td><\/tr><tr><td>Browser support<\/td><td>Needs a proxy<\/td><td>Works directly<\/td><\/tr><tr><td>Easy to debug with curl<\/td><td>No<\/td><td>Yes<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-diagram-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-diagram-2-1024x640.png\" alt=\"Go gRPC vs REST diagram comparing data format, contract, transport and streaming\" class=\"wp-image-344\" srcset=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-diagram-2-1024x640.png 1024w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-diagram-2-300x188.png 300w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-diagram-2-768x480.png 768w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-diagram-2-1536x960.png 1536w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-diagram-2-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">REST sends readable JSON over plain HTTP, while gRPC sends compact protobuf over HTTP\/2 using generated code on both sides.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">So when should you use which? Use REST for public APIs and browser apps. On the other hand, use Go gRPC for fast internal calls between your own services.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Hands-On: Build a Go gRPC Book Service<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s build a small Go gRPC library service. It will have two methods: <code>GetBook<\/code> returns one book, and <code>ListBooks<\/code> streams all books by an author.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Install the Tools<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">First, install the <code>protoc<\/code> compiler from your package manager or the protobuf releases page. Then install the two Go plugins with these commands.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>go install google.golang.org\/protobuf\/cmd\/protoc-gen-go@latest\ngo install google.golang.org\/grpc\/cmd\/protoc-gen-go-grpc@latest\nexport PATH=\"$PATH:$(go env GOPATH)\/bin\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The last line puts the plugins on your <code>PATH<\/code>, so <code>protoc<\/code> can find them.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Write the Contract<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create the file <code>library\/library.proto<\/code> with the following content.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>syntax = \"proto3\";\n\npackage library;\n\noption go_package = \"example.com\/library\/librarypb\";\n\n\/\/ BookService lets clients read books from our library.\nservice BookService {\n  rpc GetBook(GetBookRequest) returns (Book);\n  rpc ListBooks(ListBooksRequest) returns (stream Book);\n}\n\nmessage Book {\n  int32 id = 1;\n  string title = 2;\n  string author = 3;\n}\n\nmessage GetBookRequest {\n  int32 id = 1;\n}\n\nmessage ListBooksRequest {\n  string author = 1;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here, the word <code>stream<\/code> before <code>Book<\/code> makes <code>ListBooks<\/code> a server streaming call. Also, <code>go_package<\/code> tells the generator which Go import path to use.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Generate the Go Code<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now run <code>protoc<\/code> from the project root.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>protoc --go_out=. --go_opt=paths=source_relative \\\n  --go-grpc_out=. --go-grpc_opt=paths=source_relative \\\n  library\/library.proto<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">As a result, this creates <code>library.pb.go<\/code> and <code>library_grpc.pb.go<\/code> next to the proto file. One small surprise for beginners is the field names. Because protobuf follows Go naming rules, the field <code>id<\/code> becomes <code>Id<\/code> in Go, and the getter is <code>GetId()<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Write the Server<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Here is the full server. To stay simple, it keeps books in a slice instead of a database. Later in this series, we will swap the slice for PostgreSQL.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>type server struct {\n\tpb.UnimplementedBookServiceServer\n\tbooks []*pb.Book\n}\n\nfunc (s *server) GetBook(ctx context.Context, req *pb.GetBookRequest) (*pb.Book, error) {\n\tfor _, b := range s.books {\n\t\tif b.GetId() == req.GetId() {\n\t\t\treturn b, nil\n\t\t}\n\t}\n\treturn nil, status.Errorf(codes.NotFound, \"book %d not found\", req.GetId())\n}\n\nfunc (s *server) ListBooks(req *pb.ListBooksRequest, stream pb.BookService_ListBooksServer) error {\n\tfor _, b := range s.books {\n\t\tif b.GetAuthor() == req.GetAuthor() {\n\t\t\tif err := stream.Send(b); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc main() {\n\tlis, err := net.Listen(\"tcp\", \":50051\")\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to listen: %v\", err)\n\t}\n\ts := grpc.NewServer()\n\tpb.RegisterBookServiceServer(s, &amp;server{books: []*pb.Book{\n\t\t{Id: 1, Title: \"Go Basics\", Author: \"Asha\"},\n\t\t{Id: 2, Title: \"Go Testing\", Author: \"Asha\"},\n\t\t{Id: 3, Title: \"Go Web\", Author: \"Ravi\"},\n\t}})\n\tlog.Println(\"gRPC server listening on :50051\")\n\tlog.Fatal(s.Serve(lis))\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s walk through the important lines. The embedded <code>UnimplementedBookServiceServer<\/code> keeps the code compiling if the contract later gains new methods. You saw this idea in <a href=\"https:\/\/smitabharat.com\/blog\/go-struct-embedding-examples\/\">Go struct embedding<\/a>. Next, <code>status.Errorf<\/code> with <code>codes.NotFound<\/code> returns a proper gRPC error, much like a 404 in REST. Finally, <code>stream.Send<\/code> pushes each matching book to the client one at a time.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Write the Client<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The client connects and asks for one book. Then it asks for a missing book and finally reads the stream.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>func main() {\n\tconn, err := grpc.NewClient(\"localhost:50051\",\n\t\tgrpc.WithTransportCredentials(insecure.NewCredentials()))\n\tif err != nil {\n\t\tlog.Fatalf(\"did not connect: %v\", err)\n\t}\n\tdefer conn.Close()\n\tc := pb.NewBookServiceClient(conn)\n\n\tctx, cancel := context.WithTimeout(context.Background(), time.Second)\n\tdefer cancel()\n\n\tbook, err := c.GetBook(ctx, &amp;pb.GetBookRequest{Id: 1})\n\tif err != nil {\n\t\tlog.Fatalf(\"could not get book: %v\", err)\n\t}\n\tfmt.Println(\"Book:\", book.GetTitle())\n\n\t_, err = c.GetBook(ctx, &amp;pb.GetBookRequest{Id: 99})\n\tif status.Code(err) == codes.NotFound {\n\t\tfmt.Println(\"Error:\", err)\n\t}\n\n\tstream, err := c.ListBooks(ctx, &amp;pb.ListBooksRequest{Author: \"Asha\"})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfor {\n\t\tb, err := stream.Recv()\n\t\tif err == io.EOF {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tfmt.Println(\"Streamed:\", b.GetTitle())\n\t}\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>insecure.NewCredentials()<\/code> turns off TLS, which is fine on your laptop. In production, however, you must use TLS. Also, <code>status.Code(err)<\/code> reads the gRPC code from any error. So you can treat &#8220;not found&#8221; differently from a network failure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now start the server in one terminal and run the client in another. Because both use port 50051, make sure nothing else is using it. You should see this output.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Book: Go Basics\nError: rpc error: code = NotFound desc = book 99 not found\nStreamed: Go Basics\nStreamed: Go Testing<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In other words, the stream ends when the server&#8217;s <code>ListBooks<\/code> method returns. Then <code>Recv<\/code> gives <code>io.EOF<\/code>, and the loop stops.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes with Go gRPC<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Forgetting the PATH export<\/strong>: <code>protoc<\/code> then fails with &#8220;protoc-gen-go: program not found&#8221;. Add the Go bin folder to your <code>PATH<\/code>.<\/li>\n\n\n\n<li><strong>Changing field numbers<\/strong>: old clients then read the wrong data silently. So only add new numbers and never reuse old ones.<\/li>\n\n\n\n<li><strong>No timeout on calls<\/strong>: a slow server can block your client forever. Always pass a context with a deadline.<\/li>\n\n\n\n<li><strong>Returning plain errors<\/strong>: <code>errors.New<\/code> becomes <code>codes.Unknown<\/code> on the client. Use <code>status.Errorf<\/code> with a real code instead.<\/li>\n\n\n\n<li><strong>Editing generated files<\/strong>: your changes vanish on the next <code>protoc<\/code> run. Change the <code>.proto<\/code> file and regenerate.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices for Go gRPC<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>**Keep <code>.proto<\/code> files in one shared place**, because every client must use the same contract.<\/li>\n\n\n\n<li><strong>Use TLS outside your laptop<\/strong>, since <code>insecure<\/code> sends data as plain bytes.<\/li>\n\n\n\n<li><strong>Set deadlines on every call<\/strong>, so one slow service cannot freeze the chain.<\/li>\n\n\n\n<li><strong>Return precise status codes<\/strong>, because clients can then retry only when it makes sense.<\/li>\n\n\n\n<li><strong>Close streams and connections<\/strong>, as open connections hold memory on both sides.<\/li>\n\n\n\n<li><strong>Add new fields instead of changing old ones<\/strong>, so old and new versions keep working together.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Practice Task<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To practise Go gRPC, add a <code>CreateBook<\/code> method to the contract. It should take a title and an author and return the new book with an ID. Regenerate the code, then write the server method and call it from the client.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Hint: return <code>codes.InvalidArgument<\/code> when the title is empty.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These pages come from the gRPC and Go teams, so they stay accurate and current.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/grpc.io\/docs\/languages\/go\/quickstart\/\">Quick start for gRPC in Go<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/grpc.io\/docs\/languages\/go\/basics\/\">Basics tutorial for gRPC in Go<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pkg.go.dev\/google.golang.org\/grpc\">grpc package on pkg.go.dev<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/protobuf.dev\/programming-guides\/proto3\/\">Protocol Buffers proto3 language guide<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Recap<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go gRPC calls functions on other services using a shared <code>.proto<\/code> contract.<\/li>\n\n\n\n<li><code>protoc<\/code> generates message structs, a server interface and a client.<\/li>\n\n\n\n<li>gRPC uses compact protobuf messages over HTTP\/2.<\/li>\n\n\n\n<li>There are four call styles: unary, server streaming, client streaming and bidirectional.<\/li>\n\n\n\n<li>Return errors with <code>status.Errorf<\/code> and a code such as <code>codes.NotFound<\/code>.<\/li>\n\n\n\n<li>Use REST for browsers and public APIs, and gRPC for fast internal calls.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Go gRPC streams are great between services. However, browsers need something else for live updates. Next, we will build a real-time chat server with WebSockets.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next lesson: <a href=\"https:\/\/smitabharat.com\/blog\/go-websockets-chat\/\">Go WebSockets: Build a Real-Time Chat Server<\/a><\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Go gRPC lets one service call a function on another service, almost as if it were a local function. In this post, you will&hellip;<\/p>\n","protected":false},"author":1,"featured_media":342,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_swapz_level":"","_swapz_series_part":0,"_swapz_hide_toc":false,"_swapz_hide_featured":false,"_swapz_description":"","footnotes":""},"categories":[15],"tags":[66,11,23,21],"swapz_series":[],"class_list":["post-372","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-go-lang","tag-go-grpc","tag-go-lang","tag-go-tutorial","tag-golang-basics"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Go gRPC Tutorial: Build Your First gRPC Service<\/title>\n<meta name=\"description\" content=\"Learn Go gRPC step by step: write a .proto contract, generate code, build a server and client, stream data and handle errors.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/smitabharat.com\/blog\/go-grpc-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Go gRPC Tutorial: Build Your First gRPC Service\" \/>\n<meta property=\"og:description\" content=\"Learn Go gRPC step by step: write a .proto contract, generate code, build a server and client, stream data and handle errors.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smitabharat.com\/blog\/go-grpc-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"Smita Bharat - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-05-09T03:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-10T15:51:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Smita\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Smita\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-grpc-tutorial\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-grpc-tutorial\\\/\"},\"author\":{\"name\":\"Smita\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"headline\":\"Go gRPC Tutorial: Build Your First gRPC Service\",\"datePublished\":\"2026-05-09T03:30:00+00:00\",\"dateModified\":\"2026-10-10T15:51:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-grpc-tutorial\\\/\"},\"wordCount\":1530,\"publisher\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-grpc-tutorial\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-grpc-tutorial-featured.png\",\"keywords\":[\"Go gRPC\",\"Go Lang\",\"Go Tutorial\",\"Golang Basics\"],\"articleSection\":[\"Go Lang\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-grpc-tutorial\\\/\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-grpc-tutorial\\\/\",\"name\":\"Go gRPC Tutorial: Build Your First gRPC Service\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-grpc-tutorial\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-grpc-tutorial\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-grpc-tutorial-featured.png\",\"datePublished\":\"2026-05-09T03:30:00+00:00\",\"dateModified\":\"2026-10-10T15:51:16+00:00\",\"description\":\"Learn Go gRPC step by step: write a .proto contract, generate code, build a server and client, stream data and handle errors.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-grpc-tutorial\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-grpc-tutorial\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-grpc-tutorial\\\/#primaryimage\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-grpc-tutorial-featured.png\",\"contentUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-grpc-tutorial-featured.png\",\"width\":2400,\"height\":1260,\"caption\":\"Go gRPC featured image: cards for the proto contract, the server and the client\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-grpc-tutorial\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Go gRPC Tutorial: Build Your First gRPC Service\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/\",\"name\":\"Smita Bharat Blog\",\"description\":\"Golang &amp; Backend Development Tutorials and Interview Questions\",\"publisher\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"alternateName\":\"Smita Bharat\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\",\"name\":\"Smita\",\"logo\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/smitabharat.com\\\/blog\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Go gRPC Tutorial: Build Your First gRPC Service","description":"Learn Go gRPC step by step: write a .proto contract, generate code, build a server and client, stream data and handle errors.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/smitabharat.com\/blog\/go-grpc-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Go gRPC Tutorial: Build Your First gRPC Service","og_description":"Learn Go gRPC step by step: write a .proto contract, generate code, build a server and client, stream data and handle errors.","og_url":"https:\/\/smitabharat.com\/blog\/go-grpc-tutorial\/","og_site_name":"Smita Bharat - Blog","article_published_time":"2026-05-09T03:30:00+00:00","article_modified_time":"2026-10-10T15:51:16+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-featured.png","type":"image\/png"}],"author":"Smita","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Smita","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/smitabharat.com\/blog\/go-grpc-tutorial\/#article","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/go-grpc-tutorial\/"},"author":{"name":"Smita","@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"headline":"Go gRPC Tutorial: Build Your First gRPC Service","datePublished":"2026-05-09T03:30:00+00:00","dateModified":"2026-10-10T15:51:16+00:00","mainEntityOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-grpc-tutorial\/"},"wordCount":1530,"publisher":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-grpc-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-featured.png","keywords":["Go gRPC","Go Lang","Go Tutorial","Golang Basics"],"articleSection":["Go Lang"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/smitabharat.com\/blog\/go-grpc-tutorial\/","url":"https:\/\/smitabharat.com\/blog\/go-grpc-tutorial\/","name":"Go gRPC Tutorial: Build Your First gRPC Service","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-grpc-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-grpc-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-featured.png","datePublished":"2026-05-09T03:30:00+00:00","dateModified":"2026-10-10T15:51:16+00:00","description":"Learn Go gRPC step by step: write a .proto contract, generate code, build a server and client, stream data and handle errors.","breadcrumb":{"@id":"https:\/\/smitabharat.com\/blog\/go-grpc-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smitabharat.com\/blog\/go-grpc-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smitabharat.com\/blog\/go-grpc-tutorial\/#primaryimage","url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-featured.png","contentUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-grpc-tutorial-featured.png","width":2400,"height":1260,"caption":"Go gRPC featured image: cards for the proto contract, the server and the client"},{"@type":"BreadcrumbList","@id":"https:\/\/smitabharat.com\/blog\/go-grpc-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smitabharat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Go gRPC Tutorial: Build Your First gRPC Service"}]},{"@type":"WebSite","@id":"https:\/\/smitabharat.com\/blog\/#website","url":"https:\/\/smitabharat.com\/blog\/","name":"Smita Bharat Blog","description":"Golang &amp; Backend Development Tutorials and Interview Questions","publisher":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"alternateName":"Smita Bharat","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/smitabharat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339","name":"Smita","logo":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/smitabharat.com\/blog"]}]}},"_links":{"self":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/372","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/comments?post=372"}],"version-history":[{"count":1,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/372\/revisions"}],"predecessor-version":[{"id":382,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/372\/revisions\/382"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media\/342"}],"wp:attachment":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media?parent=372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/categories?post=372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/tags?post=372"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}