02 go-zero入门--微服务demo
作者:互联网
参考文档:
https://go-zero.dev/cn/micro-service.html
实践过程中,文档需要修改正的地方
修改目录文件:
创建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...
标签:02,mall,--,demo,zero,rpc,user,go 来源: https://www.cnblogs.com/haima/p/15860505.html