02 go-zero入门--微服务demo
参考文档:
https://go-zero.dev/cn/micro-service.html
视频地址:
https://space.bilibili.com/387126464/channel/series
实践过程中,文档需要修改正的地方
修改目录文件:
创建userclient/user.go文件
$ cd ~/go-zero-demo/mall/rpc
$ mkdir userclient && mv ../user/rpc/user/user.go ./userclient/
修改包名
go-zero-demo/mall/rpc/userclient/user.go里的包名
package user
改为
package userclient
下载依赖
$ cd ~/go-zero-demo/mall/user/rpc
$ go mod tidy
启动user rpc
$ go run user.go -f etc/user.yaml
Starting rpc server at 127.0.0.1:8080...
order rpc生成代码后
修改包引用
修改go-zero-demo/mall/order/api/internal/logic/getorderlogic.go
这里的
"go-zero-demo/mall/user/rpc/userclient"
改为
"go-zero-demo/mall/rpc/userclient"
下载依赖
$ cd ~/go-zero-demo/mall/order/api
$ go mod tidy
启动order rpc
$ go run order.go -f etc/order.yaml
Starting rpc server at 127.0.0.1:8080...
流程图: