github.com/little-bit-shy/go-xgz(我的项目地址)
go-xgz应用最容易的go微服务框架
1分钟即可搭建一个本人的微服务
以后我的项目为Go微服务脚手架
开发环境
Centos\Ubuntu
目录阐明
go-xgz
├─ ......
├─# 业务代码
├─internal
│ ├─# 定时工作注册层
│ ├─cli
│ ├─# 数据通讯层
│ ├─dao
│ ├─# 数据交互层
│ ├─data
│ ├─# 依赖注入层
│ ├─di
│ ├─# 服务注册层
│ ├─server
│ ├─# 服务业务层
│ ├─service
│ └─
└─
应用阐明
通信容器:make bash
拉取镜像建设容器:make build
初始化脚手架:make init
革除依赖:make clean
依赖更新:make mod
依赖查看:make tidy
我的项目打包:make install
编译proto协定(生成服务文档):make proto
编译依赖注入:make write
运行脚手架:make run
运行zipkin:make zipkin
运行jaeger:make jaeger
初始化脚手架
开发环境要求:docker
wget -qO- https://get.docker.com/ | sh
第一步:git clone -b v1.0.0 –depth=1 http://github.com/little-bit-shy/go-xgz.git
第二步:cd go-xgz && make init
我的项目初始化
初始化过程中禁止中断
旧我的项目地位为/data
旧我的项目包名为github.com/little-bit-shy/go-xgz
以后文件夹为data
初始化我的项目包名(示例:github.com/little-bit-shy/go-xgz): github.com/little-bit-shy/abc
以后包名非法
开始重构我的项目...
go: creating new go.mod: module github.com/little-bit-shy/abc
go: finding module for package github.com/olivere/elastic/v7
go: finding module for package github.com/go-playground/validator/v10
go: finding module for package github.com/shopspring/decimal
go: finding module for package github.com/google/wire
go: found github.com/google/wire in github.com/google/wire v0.5.0
go: found github.com/olivere/elastic/v7 in github.com/olivere/elastic/v7 v7.0.22
go: found github.com/shopspring/decimal in github.com/shopspring/decimal v1.2.0
go: found github.com/go-playground/validator/v10 in github.com/go-playground/validator/v10 v10.4.1
我的项目初始化实现
第三步:make run
INFO 06/24-08:28:44.707 /data/cmd/main.go:44 app start
2021/06/24 08:28:44 start watch filepath: ./configs/local
INFO 06/24-08:28:44.711 /data/vendor/github.com/go-kratos/kratos/pkg/net/http/blademaster/server.go:97 blademaster: start http listen addr: [::]:8000
[warden] config is Deprecated, argument will be ignored. please use -grpc flag or GRPC env to configure warden server.
INFO 06/24-08:28:44.712 /data/pkg/rpc/warden/server.go:329 warden: start grpc listen addr: [::]:9000
第四步:curl http://127.0.0.1:8000/call_self?name=xuguozhi
{
"code": 0,
"message": "OK",
"ttl": 1,
"data": {
"content": "who is xuguozhi"
}
}
第五步:curl http://127.0.0.1:8000/say?name=xuguozhi
{
"code":0,
"message":"OK",
"ttl":1,
"data":{
......
}
}
第六步:其余
curl http://127.0.0.1:8000/metadata
curl http://127.0.0.1:8000/debug/pprof
curl http://127.0.0.1:8000/metrics
第七步:链路跟踪
浏览器关上:http://127.0.0.1:9411