No Description

yangmao 4c3f778991 . 2 years ago
business 4c3f778991 . 2 years ago
cicd 4c3f778991 . 2 years ago
cmd 4c3f778991 . 2 years ago
config 4c3f778991 . 2 years ago
router 4c3f778991 . 2 years ago
Dockerfile 4c3f778991 . 2 years ago
Makefile 4c3f778991 . 2 years ago
README.md 4c3f778991 . 2 years ago
README_project.md 4c3f778991 . 2 years ago
access_log.log 4c3f778991 . 2 years ago
go.mod 4c3f778991 . 2 years ago
go.sum 4c3f778991 . 2 years ago
monitor_log.log 4c3f778991 . 2 years ago
task_log.log 4c3f778991 . 2 years ago
third.log 4c3f778991 . 2 years ago

README.md

go-template 项目

目录

1. 本项目介绍和使用

2. 脚手架搭建项目

脚手架使用

1、下载go-app脚本

项目地址(为gocommon框架的script分支), 下载编译此项目,最后在 /data/tmp/gocommmon/bin/go-app

rm -rf /data/tmp/gocommmon && git clone -b script git@gitea.ckfah.com/cjjy/gocommon.git /data/tmp/gocommmon && cd /data/tmp/gocommmon && make tool && cd /data/tmp/gocommmon/bin

2、使用go-app脚本构建项目

  • 使用帮助

    ➜  ~ /data/tmp/gocommmon/bin/go-app build -h
    NAME:
    build - 生成脚手架项目
    
    USAGE:
    build [command options] [arguments...]
    
    OPTIONS:
    --git ssh, -g ssh         the git ssh of go-common project (default: "git@gitea.ckfah.com/cjjy/go-template.git")
    --branch value, -b value  the git branch of go-common (default: "master")
    --dir value, -d value     the clone dir for the build project (default: "./")
    --mod value, -m value     the go mod name for the build project
    --help, -h                show help (default: false)
    
  • 构建项目

比如构建go-demo项目,需要执行: /data/tmp/gocommmon/bin/go-app build -m go-demo -d /data/test/go-demo

➜  ~ /data/tmp/gocommmon/bin/go-app build -m go-demo -d /data/test/go-demo
[GO-TOOL] 2021/04/09 18:48:00 api.go:29: [INFO] [build] command load config:
{
  "branch": "master",
  "dir": "/data/test/go-demo",
  "git": "git@gitea.ckfah.com/cjjy/go-template.git",
  "mod": "go-demo"
}
Cloning into '/data/test/go-demo'...
remote: Counting objects: 4646, done.
remote: Compressing objects: 100% (2690/2690), done.
remote: Total 4646 (delta 1697), reused 4594 (delta 1676)
Receiving objects: 100% (4646/4646), 6.66 MiB | 3.90 MiB/s, done.
Resolving deltas: 100% (1697/1697), done.
[GO-BUILD] 2021/04/09 18:48:02 [INFO] 克隆项目成功
[Shell] 2021/04/09 18:48:02 [INFO] delete file [/data/test/go-demo/.git /data/test/go-demo/README.md]
[GO-BUILD] 2021/04/09 18:48:02 [INFO] 删除 git 文件成功
[GO-BUILD] 2021/04/09 18:48:02 [INFO] 创建 README.md 文件成功
[GO-BUILD] 2021/04/09 18:48:02 [INFO] 修改模版文件: /data/test/go-demo/business/third/ebike_factory_api_third_test.go
## ......
[GO-BUILD] 2021/04/09 18:48:02 [INFO] 模版全部替换成功
[GO-BUILD] 2021/04/09 18:48:02 [INFO] copy 配置文件成功
[GO-BUILD] 2021/04/09 18:48:02 [INFO] 请输入确认依赖的组件,如果选择默认回车即可,如果不选择此组件请输入no/n即可!
## 注意这里是选择交互栏
是否使用 DB  [yes/no]:
是否使用 NacosRegister  [yes/no]:
是否使用 Pprof  [yes/no]:
是否使用 RocketMQProducer  [yes/no]:
是否使用 Redis  [yes/no]:
是否使用 Trace  [yes/no]:
是否使用 LocalCache  [yes/no]:
## 最后初始化即可
[GO-BUILD] 2021/04/09 18:49:14 [INFO] 初始化Main文件成功
[GO-BUILD] 2021/04/09 18:49:14 [INFO] 格式化代码, file: /data/test/go-demo/business/service/init_test.go
[GO-BUILD] 2021/04/09 18:49:14 [INFO] 格式化代码, file: /data/test/go-demo/business/controller/init_test.go
[GO-BUILD] 2021/04/09 18:49:14 [INFO] 格式化代码, file: /data/test/go-demo/business/controller/report_controller_test.go
[GO-BUILD] 2021/04/09 18:49:14 [INFO] 格式化代码, file: /data/test/go-demo/cmd/main.go
[GO-BUILD] 2021/04/09 18:49:14 [INFO] 格式化代码成功
[GO-BUILD] 2021/04/09 18:49:14 [INFO] 构建成功, 谢谢使用, 请切换到项目目录: /data/test/go-demo , 然后执行make命令即可运行, 或者运行 go build -race -o bin/app -v cmd/main.go

3、启动项目

➜  ~ cd /data/test/go-demo
➜  go-demo make
go build -v -ldflags "-s -w" -race  -o bin/app cmd/main.go
go-demo/business/model
go-demo/business/exception
go-demo/business/job
go-demo/business/dao
go-demo/business/dto
go-demo/business/util
go-demo/business/third
go-demo/business/service
go-demo/business/controller
go-demo/router

## .....
[GO-COMMON] 2021/04/09 18:49:56 config.go:200: [DEBUG] NacosConfig load config success, 
## .......