当前位置: 首页 > 工具软件 > Kitex > 使用案例 >

RPC 框架 Kitex 初体验 (虚拟机环境)

齐磊
2023-12-01

前提

按照 HTTP 框架 Hertz 初体验 已经完成相关环境配置

安装代码生成工具

  1. 安装 kitex
go install github.com/cloudwego/kitex/tool/cmd/kitex@latest
  1. 安装 thriftgo
go install github.com/cloudwego/thriftgo@latest

验证安装是否成功

kitex --version 
thriftgo --version

获取示例代码

  1. 在 /home/music/project 目录下创建 kitex_demo 文件夹
mkdir kitex_demo
  1. 克隆示例仓库到文件夹下

需要用 https 才能读到数据

git config --global url."https://".insteadOf git://

PS : 报错相关1

git clone git://github.com/cloudwego/kitex-examples.git

PS : 这里要把仓库的 URL 名中的 https 换成 git, 否则会报错2

此处如果出现其他报错参考引用第四条

运行示例代码

  1. 进入示例仓库的 hello 目录
cd kitex-examples/hello
  1. 运行 server
go run .
  1. 运行 client

另起一个终端后

go run ./client

更多丰富的内容参考引用第一条

引用

  1. cloudwego 的 Kitex 文档 快速上手
  2. 解决 fatal: unable to connect to github.com 问题
  3. 解决error: RPC failed; result=35, HTTP code = 0/fatal: The remote end hung up unexpectedly
  4. fatal: unable to access ‘https://github.com/…‘的解决办法

附加资料

Kitex 框架地址

注脚


  1. 报错 正克隆到 ‘kitex-examples’…
    fatal: unable to connect to github.com:
    github.com[0: 20.205.243.166]: errno=??? ↩︎

  2. 报错 正克隆到 ‘kitex-examples’…
    error: RPC failed; result=35, HTTP code = 0
    fatal: The remote end hung up unexpectedly ↩︎

 类似资料: