Skip to content

chaodada/study_grpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GRPC

mac安装 protoc 编译器

使用以下命令为 Go 安装协议编译器插件:

go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1

go get google.golang.org/grpc

参考地址 https://grpc.io/docs/languages/go/quickstart/

编写好proto文件执行以下命令生成GO文件

注意:

.proto文件中要写入option go_package="./;hello_grpc";配置,要不然会报错。

# 注意要进入到pb目录中执行
protoc --go_out=. --go_opt=paths=source_relative  --go-grpc_out=. --go-grpc_opt=paths=source_relative ./hello_grpc.proto

protobuf语法介绍

声明语法版本

syntax = "proto3";

给当前的proto分配包名称

package hello_grpc;

未完待续。。。

Releases

No releases published

Packages

No packages published

Languages