关于go:go微服务框架Kratos-连载五使用protbuf创建http服务器

1次阅读

共计 529 个字符,预计需要花费 2 分钟才能阅读完成。

一、介绍

前几张咱们曾经学了 kratos 的根本框架。本章咱们来深刻分析一下原理。
kratos 框架之所以可能应用 protbuf 创立 http 服务器,多亏了框架自带的
protoc-gen-go-http 插件。
那么咱们是否能够在其余中央应用这个插件呢,答案是能够,明天咱们就试一下。
本文章代码地址在 https://github.com/hisheng/kratos-http

1.1 筹备目录

咱们新建一个 kratos-http 目录,并且 go 模块初始化。
创立目录:

mkdir kratos-http && cd kratos-http

go 我的项目初始化:
咱们在 kratos-http 根目录执行一下代码

go mod init github.com/hisheng/kratos-http

1.2 装置 protoc-gen-go 以及 http 扩大 protoc-gen-go-http

咱们在 kratos-http 根目录执行一下代码,装置扩大。

go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@latest
正文完
 0