gozero学习之路
go-zero
开始学习go-zero咯
https://github.com/Mikaelemmmm/go-zero-looklook
环境配置
https://github.com/Mikaelemmmm/go-zero-looklook/blob/main/deploy/script/gencode/gen.sh
https://github.com/Mikaelemmmm/go-zero-looklook/tree/main/doc/chinese
go install github.com/zeromicro/go-zero/tools/goctl@latest
准备protocol goctl env check -i -f -v
使用api功能
# 生成api业务代码 , 进入"服务/cmd/api/desc"目录下,执行下面命令
goctl api go -api user.api -dir ../ -style gozero // gozero这里是生成代码的风格,驼峰下划线都能设置
go mod tidy // 把 gozero拉下来
goctl docker -go user.go // 打出来一个镜像包
goctl kube deploy -name user-api -namespace go-zero-looklook -image user-api:v1.0 -o user-api.yaml -port 1001 -nodePort 31001
goctl model mysql datasource -url="root:123456@tcp(127.0.0.1:3306)/database" -table="*" -dir="./model"
goctl rpc protoc ./rpc/user.proto --go_out=./rpc/types --go-grpc_out=./rpc/types --zrpc_out=./rpc
# 创建kafka的topic
# kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 -partitions 1 --topic {topic}
# 查看消费者组情况
# kafka-consumer-groups.sh --bootstrap-server kafka:9092 --describe --group {group}
# 命令行消费
# ./kafka-console-consumer.sh --bootstrap-server kafka:9092 --topic looklook-log --from-beginning
# 命令生产
# ./kafka-console-producer.sh --bootstrap-server kafka:9092 --topic second