All Projects → pinkhello → go-starter

pinkhello / go-starter

Licence: Apache-2.0 license
Go 服务框架脚手架. 整合 echo、swag、viper、nsq、logrus、fx、xorm、cobra 等第三方库

Programming Languages

go
31211 projects - #10 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to go-starter

go course
個人多年來學習與實作上的心得筆記
Stars: ✭ 25 (-82.76%)
Mutual labels:  viper, cobra
public
util toolkit for go.golang 通用函数包
Stars: ✭ 135 (-6.9%)
Mutual labels:  nsq, cobra
Phalgo
phalgo 已经更换为 https://github.com/sunmi-OS/gocore phalgo不在维护
Stars: ✭ 110 (-24.14%)
Mutual labels:  echo, viper
pink-lady
a template project of gin app.
Stars: ✭ 44 (-69.66%)
Mutual labels:  viper, swag
goscription
Goscription is skeleton project with simple design & clean code with Go
Stars: ✭ 36 (-75.17%)
Mutual labels:  viper, swag
go-contrib
Helper for Log configuration, Mixin for properties with fangs
Stars: ✭ 20 (-86.21%)
Mutual labels:  viper, logrus
golang-example-app
Example application
Stars: ✭ 138 (-4.83%)
Mutual labels:  viper, cobra
actions
Our Library of GitHub Actions
Stars: ✭ 49 (-66.21%)
Mutual labels:  github-actions
actions
Load secrets into GitHub Actions
Stars: ✭ 47 (-67.59%)
Mutual labels:  github-actions
AndroidVIP
Android project to experiment the VIPER approach using mosby, RxJava and dagger2
Stars: ✭ 21 (-85.52%)
Mutual labels:  viper
xunit-to-junit
This Extensible Stylesheet Language Transformations can transform a xUnit.net v2 XML test results file into a JUnit test results file.
Stars: ✭ 21 (-85.52%)
Mutual labels:  github-actions
github-pr-diff-tree
🌲 This action provide a comment that displays the diff of the pull request in a tree format.
Stars: ✭ 31 (-78.62%)
Mutual labels:  github-actions
action-branch-name
Github action to enforce naming convention on branch names
Stars: ✭ 53 (-63.45%)
Mutual labels:  github-actions
cibuildwheel
🎡 Build Python wheels for all the platforms on CI with minimal configuration.
Stars: ✭ 1,350 (+831.03%)
Mutual labels:  github-actions
action-hexo
No description or website provided.
Stars: ✭ 28 (-80.69%)
Mutual labels:  github-actions
sentry-releases-action
A GitHub action that creates releases for Sentry.io.
Stars: ✭ 38 (-73.79%)
Mutual labels:  github-actions
travis-ci-latex-pdf
Overview of different methods to build LaTeX with GitHub Actions or Travis-CI (idea by @jackolney but completely rewritten by @PHPirates and contributors).
Stars: ✭ 113 (-22.07%)
Mutual labels:  github-actions
mean-docker
A Mean stack (Angular 15.0.3, Expressjs 4.17.1, MongoDB) jump start project with support of docker.
Stars: ✭ 73 (-49.66%)
Mutual labels:  github-actions
clang-format-action
GitHub Action for clang-format checking
Stars: ✭ 48 (-66.9%)
Mutual labels:  github-actions
actions-runner-controller
Kubernetes controller for GitHub Actions self-hosted runners
Stars: ✭ 2,636 (+1717.93%)
Mutual labels:  github-actions

go-starter

github activity

Stargazers repo roster for @pinkhello/go-starter

Stargazers over time

Demo

Demo: 房产CRM

thirdparty

code layer

   - 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
     - ... 
   - ...

Build & Publish & Deploy

swag tips

> swag init -g app/main.go

swagger url: http://{IP}:{PORT}/swagger/index.html

build

  • local
    > cd .
    > docker build . --file deploy/Dockerfile --tag {ImageTag}
  • github action
    > { secrets.ACCESS_USERNAME }: `your docker hub username`

be deploy

  1. docker network:go_starter_network
    > docker network create go_starter_network
  2. mysql & nsq
    # MYSQL start
    > cd deploy/mysql
    > docker-compose up -d
    # NSQ start
    > cd deploy/nsq
    > docker-compose up -d
  3. be server
    # go-starter start
    > cd deploy
    > docker-compose up -d
  4. Health
    http://{IP}:{PORT}/

Other

  • Dockerfile

      # build go 
      FROM golang:1.16.1-alpine3.13 as builder
      ......
      RUN CGO_ENABLED=0 GOOS=linux go build -o go_starter app/main.go
      
      # package stage
      FROM alpine
      ......
      # copy from builder
      COPY --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,
        }
    )
    
    func initHTTP(cmd *cobra.Command, args []string) {
        fx.New(inject()).Run()
    }
    
    func inject() fx.Option {
        return fx.Options(
            fx.Provide(
                config.NewConfig,
                utils.NewTimeoutContext,
            ),
            libs.XormModule,
            repository.Module,
            service.Module,
            controller.Module,
            nsq.ProducerModule,
            nsq.ConsumerModule,
            http.Module,
        )
    }
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].