![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
go-zero
文章平均质量分 75
go-zero学习笔记
pyf511765
IT菜鸟
展开
-
go-zero使用etcd进行服务发现代码分析
如果需要在api中调用rpc服务 需要现在api/internal/svc/servicecontext.go中做如下更改type ServiceContext struct { Config config.Config UserRpc userclient.User //添加}func NewServiceContext(c config.Config) *ServiceContext { return &ServiceContext{ Con原创 2021-12-19 10:20:59 · 2877 阅读 · 0 评论 -
go-zero是如何加载配置文件的
先看go-zero的rpc和api的目录结构rpc:api:不管是API目录 还是在RPC目录下 配置文件存放方式都是一样的 在etc目录下有一个 yaml文件,在internal\config目录下有一个config.go 文件。查看yaml文件Name: userHost: 0.0.0.0Port: 8282Mysql: DataSource: user:password@tcp(127.0.0.1:3306)/database?charset=utf8mb4&parse原创 2021-12-18 19:05:57 · 2305 阅读 · 0 评论 -
go-zero使用Etcd进行服务注册代码分析
代码分析github.com/tal-tech/go-zero@v1.2.3/core/discov/publisher.gopackage discovimport ( "github.com/tal-tech/go-zero/core/discov/internal" "github.com/tal-tech/go-zero/core/lang" "github.com/tal-tech/go-zero/core/logx" "github.com/tal-tec原创 2021-12-18 19:21:26 · 2275 阅读 · 0 评论