/grpc_examples

Rich examples of grpc usage, helps you learn and use grpc more easily.

Primary LanguageGoMIT LicenseMIT

English | 简体中文

Description

This is a collection of commonly used gRPC knowledge points, perfect for comprehensive learning and usage of gRPC. These gRPC knowledge points are extracted from the Go development framework sponge.

Sponge is a powerful development framework that integrates automatic code generation, gin and gRPC frameworks. It greatly improves development efficiency and reduces development difficulty by providing one-stop project development from code generation, development, testing, API documentation to deployment, realizing "low-code" development projects.

Sponge Repo: https://github.com/zhufuyi/sponge


Quick Start

Go Configuration

This step can be skipped if go has already been set up.

# Linux or MacOS
export GOROOT="/opt/go"     # your go installation directory
export GOPATH=$HOME/go      # Set the directory where the "go get" command downloads third-party packages
export GOBIN=$GOPATH/bin    # Set the directory where the executable binaries are compiled by the "go install" command.
export PATH=$PATH:$GOBIN:$GOROOT/bin  # Add the $GOBIN directory to the system path.


# Windows
setx GOPATH "D:\your-directory"      # Set the directory where the "go get" command downloads third-party packages
setx GOBIN "D:\your-directory\bin"   # Set the directory where the executable binary files generated by the "go install" command are stored.

Installation of Protoc and Plugins

  1. Copy the protobuf file dependency folder include to the $GOBIN directory.

  2. Download protoc from: https://github.com/protocolbuffers/protobuf/releases/tag/v25.2

Download the protoc binaries according to the system type, move the protoc binaries to $GOBIN.

  1. Install Protoc Plugins
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest
go install github.com/envoyproxy/protoc-gen-validate@latest
go install github.com/mohuishou/protoc-gen-go-gin@latest
go install github.com/srikrsna/protoc-gen-gotag@latest

List of examples