Favicon of gRPC-Go

gRPC-Go

grpc-go is the official Go implementation of gRPC, an HTTP/2-based RPC framework for building fast, cross-language microservices.

gRPC-Go website screenshot
gRPC-Go GitHub repository preview

grpc-go is the Go language implementation of gRPC, a high performance, open source RPC framework built on HTTP/2. It's maintained by the gRPC project and used to build service-to-service APIs where performance and strong typing matter. It fits developers building Go services that need to talk to other services, whether those are also written in Go or in another language supported by gRPC.

Unlike REST-over-JSON, gRPC uses Protocol Buffers for serialization and HTTP/2 for transport, which gives you binary payloads, multiplexed streaming, and generated client/server code from .proto files. grpc-go is the reference implementation for consuming and producing gRPC services in Go.

Key features

  • HTTP/2 transport: built on HTTP/2, so it supports multiplexed connections, header compression, and bidirectional streaming out of the box.
  • Protocol Buffers integration: works with generated Go code from .proto definitions, giving you typed request/response messages and service stubs.
  • Streaming RPCs: supports unary, server-streaming, client-streaming, and bidirectional-streaming call patterns.
  • Transport credentials and auth: pluggable credential mechanisms for TLS and other authentication schemes at the transport level.
  • Keepalive and connection management: configurable keepalive parameters, including options like MaxConnectionAgeGrace to tune how long connections and in-flight RPCs stay alive.
  • Configurable logging: environment variable controls (GRPC_GO_LOG_VERBOSITY_LEVEL, GRPC_GO_LOG_SEVERITY_LEVEL) for debugging transport and connection issues.
  • Cross-language interoperability: since gRPC is language-agnostic, a Go server or client here can talk to services written in any other gRPC-supported language.

Ideal use cases

grpc-go is a good fit when you're building internal microservices that need low-latency, strongly-typed communication between Go services, or between Go and services written in other languages. It also suits systems that need streaming semantics, such as real-time data feeds, chat-like bidirectional communication, or large data transfers broken into chunks.

It's a reasonable choice for mobile or edge clients too, since gRPC was designed with mobile and HTTP/2 in mind, and for teams that already invest in Protocol Buffers as a schema definition language across services.

It is not the right choice if you need a simple, human-readable API that external partners or browsers will hit directly without a proxy. Browsers don't support gRPC natively without gRPC-Web or a translation layer, so plain REST/JSON or GraphQL may be simpler for public-facing APIs. It also adds overhead if your system is a single small service with no cross-service calls, where the tooling and code generation step isn't worth the setup.

Installation

Add the import to your Go code and let the Go toolchain fetch the dependency automatically:

import "google.golang.org/grpc"

Then run:

go build
# or
go run .
# or
go test ./...

Requirements: any of the two latest major Go releases.

If you can't reach golang.org (for example, from mainland China) and go get times out, you can alias the import using Go module's replace directive:

go mod edit -replace=google.golang.org/grpc=github.com/grpc/grpc-go@latest
go mod tidy
go mod vendor
go build -mod=vendor

Note this may need to be repeated for other transitive dependencies also hosted on golang.org.

To debug connection or transport issues, turn on verbose logging with environment variables:

export GRPC_GO_LOG_VERBOSITY_LEVEL=99
export GRPC_GO_LOG_SEVERITY_LEVEL=info

For generated service code, you'll also need the Protocol Buffers compiler (protoc) and the Go gRPC plugin, though those are covered in the official quick start docs rather than this repository directly.

Frequently asked questions

Share:

Stars
23.1K
Forks
4.8K
Last commit
2 days ago
Repository age
12 years
License
Apache-2.0
Self-hosted
No
Activity score
84/100
View Repository
Ad
Favicon

 

  
 

Similar to gRPC-Go

Favicon

 

  
 
Favicon

 

  
 
Favicon