Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lizifeng
hilo
Commits
601ef62f
Commit
601ef62f
authored
Jul 11, 2022
by
kzkzzzz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 修改readme
parent
090a171d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
42 deletions
+39
-42
README.md
README.md
+39
-42
No files found.
README.md
View file @
601ef62f
# Kratos Project Template
### 采用单体仓库monorepo方案, 基于go-kratos构建微服务, 注册中心使用consul
#### https://github.com/go-kratos/kratos
#### https://github.com/go-kratos/beer-shop
##
Install Kratos
##
# 相关目录说明
```
```
text
go install github.com/go-kratos/kratos/cmd/kratos/v2@latest
api 存放对应服务的proto文件
```
third_party 存放第三方的proto文件
## Create a service
app/service 服务
```
common 通用的工具类
# Create a template project
script 相关shell脚本
kratos new server
tool 相关工具服务
tool/gateway 开发调试网关, 例如: go run gateway.go -c 192.168.233.1:8500
cd server
```
# Add a proto template
kratos proto add api/server/server.proto
#
Generate the proto code
#
### 初始化项目, 下载依赖工具, go版本1.18以上
kratos proto client api/server/server.proto
```
shell
#
Generate the source code of service by proto fi
le
#
开启go modu
le
kratos proto server api/server/server.proto -t internal/service
go
env
-w
GO111MODULE
=
on
# 设置国内镜像
go
generate ./...
go
env
-w
GOPROXY
=
https://goproxy.cn,directc
go build -o ./bin/ ./...
./bin/server -conf ./configs
# 下载依赖
```
go mod download
## Generate other auxiliary files by Makefile
go mod tidy
```
#
Download and update dependencies
#
下载相关命令工具
make init
make init
# Generate API files (include: pb.go, http, grpc, validate, swagger) by proto file
make api
# Generate all files
make all
```
```
## Automated Initialization (wire)
```
# install wire
go get github.com/google/wire/cmd/wire
# generate wire
#### 新建服务, 主要是复制demo项目模板并进行替换
cd cmd/server
```
shell
wire
# 例如创建user服务
make service
project
=
user
```
```
## Docker
#### 开发环境运行服务
```
bash
```
shell
# build
# 运行demo服务, 修改代码自动热重载
docker build
-t
<your-docker-image-name>
.
make run
project
=
demo
```
# run
#### 编译
docker run
--rm
-p
8000:8000
-p
9000:9000
-v
</path/to/your/configs>:/data/conf <your-docker-image-name>
```
shell
make build
project
=
demo
```
```
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment