Skip to content

Day 22 - gRPC

安装

bash
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

proto文件

protobuf
syntax = "proto3";

service UserService {
    rpc GetUser(GetRequest) returns (User);
}

message GetRequest {
    int64 id = 1;
}

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

生成代码

bash
protoc --go_out=. --go_opt=paths=source_relative \
       --go-grpc_out=. --go-grpc_opt=paths=source_relative \
       user.proto

📅 学习进度

Day主题状态
01-21基础/工程
22gRPC
23Docker

本文为Go 30天学习计划第22天内容

📚 导航

| ← Day 21 - 上一章 | Day 23 - 下一章 →

最后更新: