- Notifications
You must be signed in to change notification settings - Fork30
Go 服务框架脚手架. 整合 echo、swag、viper、nsq、logrus、fx、xorm、cobra 等第三方库
License
NotificationsYou must be signed in to change notification settings
pinkhello/go-starter
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Demo:房产CRM
- url:http://121.4.242.26 (test/123456)。
- BEgo-starter
- FEant-design-vue-pro
- Github Actions
- Custom Loggerlogrus
- CLI Commandcobra
- Configurationviper
- Webecho
- DI/IOCfx
- ORMxorm
- Swagger generatorswagecho-swagger
- MessagingNSQ
- golangci-lintgolangci-lint
- Migratemigrate
- ......
- app# application main - cmd - ... - config# config - deploy# ci/cd - mysql# mysql docker-compose - nsq# nsq docker-compose - ...# other - docs# swag gen swagger2.0 doc - internal# core - controller# http handler(controller) - http# http sever startup - lib# lib - models# models - nsq# nsq producer & nsq consumer startup - repository# repository - service# service - utils# util - ... - ...
> swag init -g app/main.goswagger url: http://{IP}:{PORT}/swagger/index.html
- local
>cd.> docker build. --file deploy/Dockerfile --tag {ImageTag}
- github action
> { secrets.ACCESS_USERNAME }:`your docker hub username`
docker network:go_starter_network> docker network create go_starter_networkmysql&nsq# MYSQL start>cd deploy/mysql> docker-compose up -d# NSQ start>cd deploy/nsq> docker-compose up -d
be server# go-starter start>cd deploy> docker-compose up -d
Healthhttp://{IP}:{PORT}/
Dockerfile
# build goFROM golang:1.16.1-alpine3.13 as builder ......RUN CGO_ENABLED=0 GOOS=linux go build -o go_starter app/main.go# package stageFROM alpine ......# copy from builderCOPY --from=builder /app/go_starter /app# ......
Uber IOC/DI:fx
//other code......var (httpCmd=&cobra.Command{Use:"http",Short:"Start Http REST API",Run:initHTTP, })funcinitHTTP(cmd*cobra.Command,args []string) {fx.New(inject()).Run()}funcinject() fx.Option {returnfx.Options(fx.Provide(config.NewConfig,utils.NewTimeoutContext, ),libs.XormModule,repository.Module,service.Module,controller.Module,nsq.ProducerModule,nsq.ConsumerModule,http.Module, )}
About
Go 服务框架脚手架. 整合 echo、swag、viper、nsq、logrus、fx、xorm、cobra 等第三方库
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.