All Projects → better-go → cookiecutter-go

better-go / cookiecutter-go

Licence: Apache-2.0 license
boilerplate, golang project starter tool, support go-zero/go-micro/gin

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects
HCL
1544 projects
Makefile
30231 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to cookiecutter-go

Kotlin Android Mvp Starter
Create/Generate your kotlin MVP projects easily
Stars: ✭ 270 (+328.57%)
Mutual labels:  cookiecutter, starter
aurelia-typescript-webpack-starter
A minimal Aurelia starter kit written in TypeScript and built using webpack.
Stars: ✭ 28 (-55.56%)
Mutual labels:  skeleton, starter
Kotlin Android Mvvm Starter
Android Kotlin Starter is a starter project which implements MVVM Pattern.
Stars: ✭ 276 (+338.1%)
Mutual labels:  cookiecutter, starter
cookiecutter-pypackage
A cookiecutter template for Python package with heavy use of Github actions
Stars: ✭ 19 (-69.84%)
Mutual labels:  cookiecutter, cookiecutter-template
python-template
Netherlands eScience Center Python Template
Stars: ✭ 136 (+115.87%)
Mutual labels:  cookiecutter, cookiecutter-template
cookiedozer
📱 Cookiecutter for i18n Kivy Apps
Stars: ✭ 48 (-23.81%)
Mutual labels:  cookiecutter, cookiecutter-template
angular-cli-skeleton
angular-cli skeleton to quickly start a new project with advanced features and best practices. All features are described in README.md.
Stars: ✭ 32 (-49.21%)
Mutual labels:  skeleton, starter
cookiecutter-qt-app
A cookiecutter to create Qt applications, with translations and packaging
Stars: ✭ 29 (-53.97%)
Mutual labels:  cookiecutter, cookiecutter-template
cookiecutter-python-cli
A cookiecutter template for creating a Python CLI application using click
Stars: ✭ 65 (+3.17%)
Mutual labels:  cookiecutter, cookiecutter-template
Slim3
Slim Framework 3 Skeleton Application
Stars: ✭ 70 (+11.11%)
Mutual labels:  skeleton, starter
cookiecutter-flask-skeleton
Flask Starter Project
Stars: ✭ 56 (-11.11%)
Mutual labels:  cookiecutter, cookiecutter-template
FastAPI-template
Feature rich robust FastAPI template.
Stars: ✭ 660 (+947.62%)
Mutual labels:  cookiecutter, cookiecutter-template
fastapi-starter
A FastAPI based low code starter: Async SQLAlchemy, Postgres, React-Admin, pytest and cypress
Stars: ✭ 97 (+53.97%)
Mutual labels:  cookiecutter, cookiecutter-template
cookiecutter-homeassistant-component
A cookiecutter project template for generating the structure for a new custom component.
Stars: ✭ 22 (-65.08%)
Mutual labels:  cookiecutter, cookiecutter-template
at-python-template
The official Python Project Template of Alexander Thamm GmbH
Stars: ✭ 34 (-46.03%)
Mutual labels:  cookiecutter, cookiecutter-template
Cookiecutter Data Science
A logical, reasonably standardized, but flexible project structure for doing and sharing data science work.
Stars: ✭ 5,271 (+8266.67%)
Mutual labels:  cookiecutter, cookiecutter-template
cookiecutter-modern-pypackage
Cookiecutter template for a modern Python package.
Stars: ✭ 97 (+53.97%)
Mutual labels:  cookiecutter, cookiecutter-template
qt-qml-project-template-with-ci
Template for a Qt/QML application with batteries included: GitHub C.I. for your QML app; automated gui testing with Xvfb; automatic code-format checks and more. Compiles for Desktop and Mobile (Linux, Mac, Windows, and Android).
Stars: ✭ 33 (-47.62%)
Mutual labels:  cookiecutter, cookiecutter-template
Angular Skeleton App
Angular 7.x navigation skeleton project with styling which get you started faster.
Stars: ✭ 25 (-60.32%)
Mutual labels:  skeleton, starter
theme-cookiecutter
A cookiecutter template to help you make new JupyterLab theme extensions
Stars: ✭ 47 (-25.4%)
Mutual labels:  cookiecutter, cookiecutter-template

English | 简体中文

go-template

  • boilerplate, go project starter with go-zero/gin/go-micro.
  • go microservice (go-zero/gin/go-micro) project directory generation tool/scaffold.
  • Implementation based on cookiecutter.

Feature:

  • mono repo: support creating mono repo, the git project root directory.
  • single app: support creating single app, a single microservice directory.
  • can be used individually or in combination
  • usage:
    • Create the mono-repo root directory first
    • Switch to app/, create single app single microservice directory.

Development Roadmap:

Intro:

  • go-zero microservice:
    • Integrate air tool, watch project code, automatic compilation + hot reload, make go development smoother (like Python/Js)
    • rpc: integrated grpc
    • log: integrated uber log
    • db: integrate gorm + mysql
    • cache: integrate redis
    • mq: integrate rabbitmq
    • Service Discovery: Integrate etcd
    • cronjob: integrate cronjob
  • go-kratos microservice:
    • Integrate go-kratos scaffolding built-in components
    • integrated air tool
    • integrated grpc/http
  • gin microservice:
    • Integrate air tool, watch project code, automatic compilation + hot reload, make go development smoother (like Python/Js)
    • rpc: integrated grpc
    • log: integrated uber log
    • db: integrate gorm + mysql
    • cache: integrate redis
    • mq: integrate rabbitmq
    • Service Discovery: Integrate etcd
    • cronjob: integrate cronjob
  • go-micro microservice:
    • Integrate air tool, watch project code, automatic compilation + hot reload, make go development smoother (like Python/Js)
    • rpc: integrated grpc
    • log: integrated uber log
    • db: integrate gorm + mysql

User Case:

Quick Start:

Install:

# Mac OS X install cookiecutter:
brew install cookiecutter

# Python + pipx:
brew install pipx
pipx ensurepath
pipx install cookiecutter

# Debian/Ubuntu:
sudo apt-get install cookiecutter

Best Practice:

  • choice 1: create mono-repo + single-app
    • support templates:
      • go-zero
      • gin
      • go-micro
  • choice 2: create library-repo

1. Mono-Repo + Single-App

  • 1.1 create mono repo:

git repo / project root.

Elevate according to command line parameters, gradually create.

cd your-workspace/

# In the current directory, create the root directory of the go-zero mono repo project
cookiecutter https://github.com/better-go/cookiecutter-go.git --directory="mono-repo/go-zero"


# In the current directory, create the gin mono repo project root directory
cookiecutter https://github.com/better-go/cookiecutter-go.git --directory="mono-repo/gin"


# In the current directory, create the root directory of the go-micro mono repo project
cookiecutter https://github.com/better-go/cookiecutter-go.git --directory="mono-repo/go-micro"


  • 1.2 create single app folder:
cd your-mono-repo-app-create-root/


# In the current directory, create a microservice directory: use go-zero
cookiecutter https://github.com/better-go/cookiecutter-go.git --directory="single-app/go-zero"


# In the current directory, create a microservice directory: use gin
cookiecutter https://github.com/better-go/cookiecutter-go.git --directory="single-app/gin"

# In the current directory, create a microservice directory: use go-micro
cookiecutter https://github.com/better-go/cookiecutter-go.git --directory="single-app/go-micro"


  • tips:
    • Path parameters, do not add suffix : /
    • If go_module_name is different from project_folder_name, be careful not to pass it wrong.

2. create library repo:

  • library-repo
cd your-workspace/

# In the current directory, create the mono repo project root directory:
cookiecutter https://github.com/better-go/cookiecutter-go.git --directory="library-repo"

Generate Project Folder Structure:

  • Mono Repo:

  • Brief description of directory structure: a quick look of the overall directory.

-> % tree . -L 3
.
├── app
│ ├── basic // Basic services: usually business-agnostic
│ │ ├── demo // Example:
│ │ └── user // user management:
│  ├── biz // Business Services: Segmentation according to business
│ │ └── member // Member service:
│ │ └── order // order service:
│ │ └── cart // Shopping cart service:
│ └── std // Unified definition within the business:
│ ├── proto // Unified definition of business status code
├── deploy // deployment script, service orchestration
│   ├── local
│   │   └── Makefile
│   └── staging
│       └── Makefile
├── infra // infrastructure
│   └── tool
└── pkg // Utility code base accumulated by the project, not related to business
  • Detailed description of directory structure:
-> % tree . -L 6
.
├── LICENSE
├── Makefile
├── README.MD
├── app
│ ├── basic // Basic service unit 1: general services unrelated to user management/push/SMS/etc.
│ │ ├── demo // Example of a single microservice:
│ │ │ │ ├── cmd // Single-service startup entry: including multiple startup methods:
│   │   │   │   └── main.go                         // api server, grpc server, job server, admin server 启动
│ │ │ │ ├── configs // External middleware configuration items: db, cache, mq, etc.
│   │   │   │   └── configs.toml
│ │ │ │ ├── docs // single-service documentation
│ │ │ │ ├── internal // business logic (not exposed)
│ │ │ │ │ ├── dao // data layer read/write
│ │ │ │ │ │ │ ├── cache // cache r/w
│   │   │   │   │   ├── db                          //      db crud
│ │ │ │ │ │ ├── http // Call http api outside this service
│ │ │ │ │ │ ├── meta.go // dao resource convergence
│   │   │   │   │   ├── mq                          //      mq r/w
│ │ │ │ │ │ └── rpc // call rpc(gRPC) api outside this service
│ │ │ │ │ ├── domain // In-service business split:
│ │ │ │ │ │ └── demo // Business Unit 1 / Business Unit 2
│ │ │ │ │ └── service // API convergence layer (external convergence internal logic, exposed API: grpc/http/job/admin)
│   │   │   │       └── service.go
│ │ │ │ └── proto // Data definition layer: (exposed to the outside world)
│ │ │ │ ├── api // grpc + http api definition
│   │   │       │   └── api.proto
│ │ │ │ ├── config // config toml mapping model
│   │   │       │   └── config.proto
│ │ │ └── model // internal model
Model │ │ └── model.proto
│ │ └── user // Basic service 2:
│ │ ├── identity // within the service
│   │       │   ├── Makefile
│   │       │   ├── cmd
│   │       │   │   └── main.go
│   │       │   ├── configs
│   │       │   │   └── configs.toml
│   │       │   ├── docs
│   │       │   ├── internal
│   │       │   │   ├── dao
│   │       │   │   ├── domain
│   │       │   │   └── service
│   │       │   ├── proto
│   │       │   │   ├── api
│   │       │   │   ├── config
│   │       │   │   └── model
│   │       │   └── readme.md
│   │       └── readme.md
│ ├── biz // Specific business unit:
│ │ │── member // Member service
│   │   │   └── cmd
│   │   │       └── main.go
│ │ └── order // order service
│   │       └── cmd
│   │           └── main.go
│ └── std // Unified definition within the project business (business status code, business error msg number)
│       ├── Makefile
│       ├── proto
│       │   ├── config
│       │   │   └── config.proto
│       │   └── error
│ │ └── code.proto // business status code
│       └── readme.md
├── deploy // Deploy related scripts: dockerfile etc.
│   ├── local
│   │   └── Makefile
│   └── staging
│       └── Makefile
├── go.mod
├── go.sum
├── infra // Plugin dependent services: cli, middleware, etc.
│   └── tool
└── pkg // Utility code base gradually accumulated in the project

46 directories, 24 files
  • single app:
-> % tree -L 3 ./single-app/{{cookiecutter.app_name}}
./single-app/{{cookiecutter.app_name}}
├── cmd
│   └── main.go
├── configs
│   └── configs.toml
├── internal
│   └── dao
│       └── db
├── proto
│   └── api
│       └── api.go
└── readme.md

7 directories, 4 files

Call link description:

  • Code call link description: Take the app/basic/demo service as an example (top-down call)
    • Cmd startup entry: app/basic/demo/cmd/main.go
    • Service 入口: app/basic/demo/internal/service/service.go
      • External API Gateway: app/basic/demo/internal/service/outer/outer.go
      • Inbound RPC gateway: app/basic/demo/internal/service/inner/inner.go
      • Internal Admin API Gateway: app/basic/demo/internal/service/admin/admin.go
      • Internal Job Gateway: app/basic/demo/internal/service/job/job.go
    • Proto data definition: --API layers: app / basic / demo / proto / api / api.proto
      • Config 层: app/basic/demo/proto/config/config.proto
      • Model 层: app/basic/demo/proto/model/model.proto
    • Router route registration: app/basic/demo/internal/router/router.go
    • Domain business areas:
      • A business unit: app/basic/demo/internal/domain/demo/demo.go
    • Dao data layer operations:
      • Meta aggregation (convergence of Dao layer resources): app/basic/demo/internal/dao/meta.go
      • DB 层: app/basic/demo/internal/dao/db/db.go
      • Cache 层: app / basic / demo / internal / dao / cache / cache.go

User Manual:

Reference:

Contributors:

Henry.Huang/
Henry.Huang
Ferris/
Ferris
Mourad
Mourad Maatoug
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].