【后端开发】字节跳动青训营Cloudwego脚手架

Cloudwego脚手架使用

cwgo脚手架

  1. 安装的命令:
bash 复制代码
GOPROXY=https://goproxy.cn/,direct go install github.com/cloudwego/cwgo@latest
  1. 依赖thriftgo的安装:
bash 复制代码
go install github.com/cloudwego/thriftgo@latest
  1. 编辑echo.thrift文件用于生成项目:
powershell 复制代码
namespace go api

struct Request {
    1: string message
}

struct Response {
    1: string message //注意这里前面的是数字1不是字母l
}

service Echo {
    Response echo(1: Request req)
}
  1. 在demo/demo_thrift目录下生成代码:
bash 复制代码
cwgo server --type RPC --module github.com/cloudwego/biz-demo/gomall/demo/demo_thrift --service demo_thrift --idl ../../idl/echo.thrift

最后得到如下结果:

相关推荐
newerp7 小时前
Golang 调度循环:Go runtime 如何永不停歇地找人干活
后端·程序员·go
小满zs1 天前
Go语言第十一章(协程)
后端·go
newerp2 天前
Golang 函数调用的瞬间:栈帧、拷贝栈与逃逸分析
后端·程序员·go
newerp2 天前
Golang 网络轮询器 netpoll:把阻塞 IO 变成事件通知
后端·程序员·go
合橱瑰2 天前
从“假智能”到“真闭环”:Go 向量推理引擎的零硬编码调优实践
后端·go
名字还没想好☜2 天前
Go 的 TCP 粘包与拆包:用长度前缀协议 + bufio 正确读消息
后端·tcp/ip·golang·go·php
Zenova EdgeOS2 天前
Go 工业边缘 Protobuf 实战:从 proto 到 Marshal 的完整落地
物联网·go·边缘计算·序列化·protobuf·工业边缘
MeetTanG3 天前
Go 实战锦囊|errgroup:优雅地管理并发任务组
后端·go
名字还没想好☜3 天前
Go 标准库 flag 包实战:参数解析、子命令、自定义 Value 类型与默认值
开发语言·后端·golang·go
天天喝旺仔3 天前
gRPC 流式通信实战:从一元调用到双向流,吃透四种 RPC 模式(Go 版)
分布式·http·微服务·rpc·go